<template>
  <div class="d-flex">
    <div class="mr-2">
      <div class="d-flex justify-content-between mb-1" style="width: 842px">
        <div class="d-flex" style="flex: 1">
          <div v-show="!viewMode" class="mr-2">
            <el-button
              type="primary"
              size="small"
              style="min-width: 100px"
              :loading="saveLoading"
              @click="onSave"
            >
              <i class="fa fa-save"></i>
              保存
            </el-button>
            <el-button
              type="primary"
              v-if="showRatingReport"
              plain
              size="small"
              @click="onFinishCencus"
            >
              <i class="fa fa-check-circle"></i>
              完成报告
            </el-button>
          </div>
          <div>
            <el-button type="primary" plain size="small" @click="getData()">
              <i class="fa fa-refresh"></i>
              刷新
            </el-button>
            <el-button type="primary" plain size="small" @click="onPrint">
              <i class="fa fa-print"></i>
              打印
            </el-button>
          </div>
        </div>
        <h5 class="text-muted" v-show="!viewMode">预览</h5>
      </div>
      <div
        class="card scroll-y p-5"
        v-loading="loading"
        :style="{ height: viewMode ? 'auto' : `${height}px` }"
        id="report-body"
      >
        <div class="report-body" style="font-family: FangSong; font-size: 2rem; line-height: 2">
          <div style="page-break-after: always">
            <div
              style="
                display: flex;
                align-items: flex-end;
                justify-content: space-between;
                padding-bottom: 0.25rem;
                margin-bottom: 0.5rem;
                border-bottom: 1px solid #ccc;
                font-family: SimSun;
              "
            >
              <div style="width: 120px">
                <img height="36" :src="orgLogo" />
              </div>
              <span style="font-size: 1rem; color: #999">{{ org.orgName }}</span>
              <span style="font-size: 1rem; color: #999">贵州为米科技有限公司</span>
            </div>

            <p style="font-family: SimSun">黔农易贷客户信用评级报告</p>
            <p style="text-align: right; font-size: 2rem; font-family: SimSun">
              项目编号：{{ dataCensus.census_number }}
            </p>

            <div style="text-align: center">
              <div
                style="
                  display: inline-block;
                  margin: 100px 0 40px 0;
                  text-align: center;
                  font-size: 1.5rem;
                  line-height: 1.428;
                  padding: 0 20px;
                  border-bottom: 1px solid #333;
                "
              >
                {{ dataBase.customer_name }}
              </div>
            </div>

            <h2
              style="
                text-align: center;
                font-size: 3rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 20px;
              "
            >
              信&nbsp;用&nbsp;评&nbsp;级&nbsp;报&nbsp;告
            </h2>

            <p style="text-align: center; font-family: SimSun">
              （有效期自{{ startValidityPeriod }}至{{ endValidityPeriod }}）
            </p>

            <table class="table" style="margin: 360px 0 200px 0; width: 100%">
              <colgroup>
                <col width="35%" />
                <col width="65%" />
              </colgroup>
              <tbody>
                <tr>
                  <td style="text-align: right; border: none; vertical-align: top">评级机构：</td>
                  <td style="border: none; vertical-align: top">{{ org.orgName }}</td>
                </tr>
                <tr>
                  <td style="text-align: right; border: none; vertical-align: top">评级时间：</td>
                  <td style="border: none; vertical-align: top">{{ startValidityPeriod }}</td>
                </tr>
              </tbody>
            </table>
          </div>

          <hr class="d-print-none" />

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 80px;
              "
            >
              声&nbsp;明&nbsp;与&nbsp;保&nbsp;证
            </h2>

            <p class="text-indent" style="margin-bottom: 200px">
              我们在此声明与保证：此报告是按照《铜仁市农业信贷担保有限责任公司客户信用评级工作管理办法（试行）》，参考中国农担集团涉农经营主体信用评级指标模型，对客户的各项资料经过审慎调查、核实、分析和整理后，依托信用评级系统完成。我们对评级报告的真实性、准确性和完整性负责。
            </p>

            <div style="text-align: right; margin-bottom: 1rem">
              <span>直接评价人员签字：</span>
              <div style="display: inline-block; width: 130px; border-bottom: 1px solid #333">
                &nbsp;
              </div>
            </div>
            <p style="text-align: right">&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;月&nbsp;&nbsp;日</p>
            <div style="text-align: right; margin-bottom: 1rem">
              <span>评价审查人员签字：</span>
              <div style="display: inline-block; width: 130px; border-bottom: 1px solid #333">
                &nbsp;
              </div>
            </div>
            <p style="text-align: right">&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;月&nbsp;&nbsp;日</p>
          </div>

          <hr class="d-print-none" />

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 40px;
                letter-spacing: 4rem;
                padding-left: 4rem;
              "
            >
              目录
            </h2>

            <ul class="list-unstyled" style="margin-bottom: 40px">
              <li v-for="(item, index) in dataMenu" :key="index">
                <a
                  href="javascript:;"
                  style="
                    color: #333;
                    text-decoration: none;
                    font-weight: bold;
                    display: flex;
                    align-items: center;
                  "
                  class=""
                  :class="{ 'pl-5': item.dir_lever === '3' }"
                  v-anchor="`anchor-${item.dir_lever}-${item.order_num}`"
                >
                  <div>{{ item.dir_name }}</div>
                  <div class="flex-grow-1 d-flex align-items-center px-1">
                    <div style="border-bottom: 1px dotted #333; flex: 1"></div>
                  </div>
                  <div>{{ item.dir_page_num }}</div>
                </a>
              </li>
            </ul>
          </div>

          <hr class="d-print-none" />

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 40px;
              "
              id="anchor-desc"
            >
              报 告 摘 要
            </h2>

            <table
              class="table table-bordered table-striped table-border-black"
              style="font-family: SimSun"
            >
              <colgroup>
                <col width="21%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="13%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
              </colgroup>
              <tbody>
                <tr>
                  <td colspan="8" style="background-color: #aaa; text-align: center">基本信息</td>
                </tr>
                <tr>
                  <td>企业名称</td>
                  <td colspan="7">{{ dataBase.customer_name }}</td>
                </tr>
                <tr>
                  <td>统一社会信用代码</td>
                  <td colspan="7">{{ dataBase.register_no }}</td>
                </tr>
                <tr>
                  <td>法人/经营者姓名</td>
                  <td colspan="3">{{ dataBase.corp_name }}</td>
                  <td colspan="2">实际控制人</td>
                  <td colspan="2">{{ dataInfoControl.real_name }}</td>
                </tr>
                <tr>
                  <td>经营地址</td>
                  <td colspan="7">{{ dataBase.address }}</td>
                </tr>
                <tr>
                  <td>法人/经营者住址</td>
                  <td colspan="7">{{ dataInfoLegal.address }}</td>
                </tr>
                <tr>
                  <td>注册日期</td>
                  <td colspan="3">
                    {{ $utils.dateFormat(dataBaseInfo.established_date, 'yyyy.MM.dd') }}
                  </td>
                  <td>经营年限</td>
                  <td colspan="3">{{ dataBaseInfo.bussiness_years }}年</td>
                </tr>
                <tr>
                  <td>所属行业</td>
                  <td colspan="3">{{ enumFarmType[dataBase.farm_type] }}</td>
                  <td>主营业务</td>
                  <td colspan="3">{{ dataProductMain.product_name }}</td>
                </tr>
                <tr>
                  <td>经营规模</td>
                  <td colspan="3">{{ dataProductMain.scale }}{{ dataProductMain.uscale }}</td>
                  <td>产能产量</td>
                  <td colspan="3">
                    {{ dataProductMain.current_year_output }}{{ dataProductMain.output_unit }}
                  </td>
                </tr>
                <tr>
                  <td>用工总数</td>
                  <td>{{ dataCustomerEmp.emp_total }}</td>
                  <td>常用</td>
                  <td>{{ dataCustomerEmp.emp_com_used }}</td>
                  <td>临时</td>
                  <td>{{ dataCustomerEmp.emp_temp }}</td>
                  <td>贫困户</td>
                  <td>{{ dataCustomerEmp.poverty_households }}</td>
                </tr>
                <tr>
                  <td>经营许可</td>
                  <td colspan="7">{{ dataBaseInfo.intellectual_property_des }}</td>
                </tr>
                <tr>
                  <td colspan="8" style="background-color: #aaa; text-align: center">
                    财务信息（单位：元）
                  </td>
                </tr>
                <tr>
                  <td>累积投入</td>
                  <td colspan="7">{{ dataFunds.inputs | pureUnit('万元') }}</td>
                </tr>
                <tr>
                  <td>上年收入</td>
                  <td>{{ dataBase.last_year_income | pureUnit('万元') }}</td>
                  <td colspan="2">今年收入</td>
                  <td>{{ dataBase.current_year_income | pureUnit('万元') }}</td>
                  <td colspan="2">下年收入（计划）</td>
                  <td>{{ dataBase.next_year_income | pureUnit('万元') }}</td>
                </tr>
                <tr>
                  <td>累积负债</td>
                  <td>{{ dataFunds.debt | pureUnit('万元') }}</td>
                  <td colspan="2">累积自有资金</td>
                  <td>{{ dataFunds.funds | pureUnit('万元') }}</td>
                  <td colspan="2">自有资金占比</td>
                  <td>{{ dataFundsPercent }}</td>
                </tr>
              </tbody>
            </table>
          </div>

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 40px;
              "
              id="anchor-conc"
            >
              报 告 结 论
            </h2>

            <p style="font-weight: bold">一、大数据评级结果</p>

            <p>评级得分：{{ dataScoreApiScore }} 分，对应等级：{{ dataScoreApiLevel }} 级</p>

            <div style="line-height: 1.5; font-size: 1.5rem; margin-bottom: 1rem">
              <div class="d-flex">
                <div style="width: 50px">&nbsp;</div>
                <div style="flex: 1; position: relative; height: 65px">
                  <div
                    style="position: absolute; top: 0"
                    :style="{ left: `${+dataScoreApiScore - 0.5}%` }"
                  >
                    <div>{{ dataScoreApiScore }}</div>
                    <i class="fa fa-long-arrow-down"></i>
                  </div>
                </div>
              </div>
              <div class="d-flex">
                <div style="width: 50px">分值</div>
                <div style="flex: 1; display: flex">
                  <span
                    v-for="(s, i) in scoreLevel"
                    :key="i"
                    style="flex: 1; text-align: right; padding-right: 5px"
                    :style="{ backgroundColor: s.color }"
                  >
                    {{ s.score }}
                  </span>
                </div>
              </div>
              <div class="d-flex">
                <div style="width: 50px">等级</div>
                <div
                  style="
                    flex: 1;
                    display: flex;
                    border-left: 1px solid #333;
                    border-top: 1px solid #333;
                  "
                >
                  <span
                    v-for="(d, j) in levelDivide"
                    :key="j"
                    style="
                      text-align: center;
                      border-right: 1px solid #333;
                      border-bottom: 1px solid #333;
                    "
                    :style="{ flex: d.area }"
                  >
                    {{ d.label }}
                  </span>
                </div>
              </div>
            </div>

            <p style="font-weight: bold">二、各模块得分</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <colgroup>
                <col width="40%" />
                <col width="20%" />
                <col width="20%" />
                <col width="20%" />
              </colgroup>
              <thead>
                <tr>
                  <th>评分模块</th>
                  <th class="text-center">模块分值占比</th>
                  <th class="text-center">指标得分</th>
                  <th class="text-center">总得分</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(item, index) in dataScoreFirstList" :key="index">
                  <td>{{ item.name }}</td>
                  <td class="text-center">{{ item.totalScore }}%</td>
                  <td class="text-center">{{ item.score }}</td>
                  <td
                    v-if="index === 0"
                    class="text-center"
                    style="vertical-align: middle"
                    :rowspan="dataScoreFirstList.length + dataScoreLoseList.length"
                  >
                    {{ dataScoreApiScore }}
                  </td>
                </tr>
                <tr v-for="(lose, serial) in dataScoreLoseList" :key="`lose${serial}`">
                  <td>{{ lose.first_level_norm_name }}</td>
                  <td class="text-center">{{ lose.norm_weight }}</td>
                  <td class="text-center">{{ lose.weight_score }}</td>
                </tr>
              </tbody>
            </table>

            <p style="font-weight: bold" id="anchor-conc-3">三、大数据信用评分风险提示</p>

            <div class="text-indent" id="anchor-conc-3-1">
              1、信用风险：
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-conc-3-1'"
              >
                {{ dataCensus.credit_risk_analysis }}
              </div>
            </div>

            <div class="text-indent" id="anchor-conc-3-2">
              2、偿债风险：
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-conc-3-2'"
              >
                {{ dataCensus.debt_risk_analysis }}
              </div>
            </div>

            <p style="font-weight: bold" id="anchor-conc-4">四、直接评价人员建议</p>

            <div class="text-indent" id="anchor-conc-4-1">
              <span>授信评估额度：</span>
              &nbsp;
              <span
                class="edit-eara d-inline-block px-2 text-center"
                style="text-indent: 0"
                v-anchor:report-edit.focus="'form-conc-4-1'"
              >
                {{ dataCensus.eva_funds }}
              </span>
              <span>&nbsp;万元</span>
            </div>

            <div class="text-indent" id="anchor-conc-4-2">
              理由说明：
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-conc-4-2'"
              >
                {{ dataCensus.eva_reason }}
              </div>
            </div>

            <div style="text-align: right; margin-bottom: 40px; margin-top: 80px">
              <span>直接评价人员签字:</span>
              <div style="display: inline-block; width: 100px; border-bottom: 1px solid #333">
                &nbsp;
              </div>
            </div>
          </div>

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 40px;
              "
              id="anchor-1"
            >
              一、经营分析
            </h2>

            <p style="font-weight: bold" id="anchor-1-1">1. 行业分析</p>

            <p class="text-indent" id="anchor-1-1-1">1.1 PEST分析</p>

            <div
              class="mb-3"
              :style="{ backgroundImage: `url(${pestImage})` }"
              style="
                background-repeat: no-repeat;
                background-position: center center;
                line-height: 1.5;
                font-size: 1.5rem;
              "
            >
              <div class="d-flex">
                <div
                  style="flex: 1; min-height: 200px; border-left: 5px solid #b3d133"
                  class="edit-eara"
                  id="anchor-1-1-1-p"
                  v-anchor:report-edit.focus="'form-1-1-p'"
                  v-html="formatLine(dataPest.p)"
                ></div>
                <div style="width: 200px"></div>
                <div
                  style="
                    flex: 1;
                    min-height: 200px;
                    border-right: 5px solid #8cc43f;
                    text-align: right;
                  "
                  class="edit-eara"
                  id="anchor-1-1-1-e"
                  v-anchor:report-edit.focus="'form-1-1-e'"
                  v-html="formatLine(dataPest.e)"
                ></div>
              </div>
              <div style="height: 40px"></div>
              <div class="d-flex">
                <div
                  style="flex: 1; min-height: 200px; border-left: 5px solid #20c7f3"
                  class="edit-eara"
                  id="anchor-1-1-1-s"
                  v-anchor:report-edit.focus="'form-1-1-s'"
                  v-html="formatLine(dataPest.s)"
                ></div>
                <div style="width: 200px"></div>
                <div
                  style="
                    flex: 1;
                    min-height: 200px;
                    border-right: 5px solid #67ae44;
                    text-align: right;
                  "
                  class="edit-eara"
                  id="anchor-1-1-1-t"
                  v-anchor:report-edit.focus="'form-1-1-t'"
                  v-html="formatLine(dataPest.t)"
                ></div>
              </div>
            </div>

            <p class="text-indent" id="anchor-1-1-2">1.2 行业发展状况分析</p>

            <div v-for="(item, index) in dataIndustryAnalysis" :key="index">
              <p class="text-indent">（{{ index + 1 }}.1）主营产品价格趋势图</p>

              <chart-market-average
                :img-type="true"
                :width="760"
                :category-code="item.category_code"
                :show-chart="item.price_analysis_dim"
              ></chart-market-average>

              <p class="text-indent">分析：</p>
              <div
                class="edit-eara text-indent"
                :id="`anchor-1-1-2-1-${index}`"
                v-anchor:report-edit.focus="`form-1-1-2-1-${index}`"
              >
                {{ item.price_analysis }}
              </div>

              <p class="text-indent">（{{ index + 1 }}.2）主营产品原材料价格趋势图</p>

              <chart-market-average
                :img-type="true"
                :width="760"
                :category-code="item.material_category_code"
                :show-chart="item.material_analysis_dim"
              ></chart-market-average>

              <p class="text-indent">分析：</p>
              <div
                class="edit-eara text-indent"
                :id="`anchor-1-1-2-2-${index}`"
                v-anchor:report-edit.focus="`form-1-1-2-2-${index}`"
              >
                {{ item.material_analysis }}
              </div>
            </div>

            <p class="text-indent" id="anchor-1-1-3">1.3 行业地位</p>

            <p class="text-indent">（1）区域内行业地位</p>

            <chart-market-scale
              :img-type="true"
              :width="760"
              :uscale="dataProductMain.uscale"
              :farm-id="dataBaseInfo.customer_id"
              :category-code="dataProductMain.category_code"
            ></chart-market-scale>

            <div class="text-indent" id="anchor-1-1-3-1">
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-1-3-1'">
                {{ dataPositAnalysis.rank_analysis }}
              </div>
            </div>

            <p class="text-indent">（2）所在区域的产业集中度情况</p>

            <chart-market-area
              title="各区县产业集中度"
              :img-type="true"
              :width="760"
              :address-code="infoAddressCodeCity"
              :category-code="dataProductMain.category_code"
            ></chart-market-area>

            <div class="text-indent mb-3" id="anchor-1-1-3-2">
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-1-3-2'">
                {{ dataPositAnalysis.concent_analysis }}
              </div>
            </div>

            <chart-market-area
              title="各乡镇产业集中度"
              :img-type="true"
              :width="760"
              :address-code="infoAddressCodeTown"
              :category-code="dataProductMain.category_code"
            ></chart-market-area>

            <div class="text-indent" id="anchor-1-1-3-3">
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-1-3-3'">
                {{ dataPositAnalysis.concent_analysis_vil }}
              </div>
            </div>

            <p style="font-weight: bold" id="anchor-1-2">2. 经营分析</p>

            <div class="text-indent" id="anchor-1-2-1">
              2.1 历史沿革
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-1-2-1'"
              >
                {{ dataCensus.business_history }}
              </div>
            </div>

            <div class="text-indent" id="anchor-1-2-2">
              2.2 经营业务
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-1-2-2'"
              >
                {{ dataCensus.business_des }}
              </div>
            </div>

            <div class="text-indent" id="anchor-1-2-3">
              2.3 经营模式
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-1-2-3'"
              >
                {{ dataCensus.business_model }}
              </div>
            </div>

            <p class="text-indent">（1）采购模式</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <colgroup>
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>供应商名</td>
                  <td>商品名称</td>
                  <td>单价（元）</td>
                  <td>数量</td>
                  <td>数量单位</td>
                  <td>金额（万元）</td>
                  <td>合作年限</td>
                  <td>备注</td>
                </tr>
                <template v-if="dataBusinessSupplier.length">
                  <tr v-for="(item, index) in dataBusinessSupplier" :key="index">
                    <td>{{ item.sm_name }}</td>
                    <td>{{ item.sm_product }}</td>
                    <td>{{ item.unit }}</td>
                    <td>{{ item.current_year_amount }}</td>
                    <td>{{ item.unit }}</td>
                    <td>{{ item.current_year_total }}</td>
                    <td>{{ item.coo_years }}</td>
                    <td>{{ item.remark }}</td>
                  </tr>
                </template>
                <tr v-else>
                  <td v-for="i in 8" :key="`bSupplier-empty-${i}`">-</td>
                </tr>
                <tr>
                  <td colspan="5" class="text-center">合计金额</td>
                  <td colspan="3" class="text-center">
                    {{ dataBusinessSupplierFunds | pureUnit('万元') }}
                  </td>
                </tr>
              </tbody>
            </table>

            <div class="text-indent" id="anchor-1-2-3-1">
              采购模式分析：
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-1-2-3-1'"
              >
                {{ dataCensus.purchase_model_des }}
              </div>
            </div>

            <div class="text-indent" id="anchor-1-2-3-2">
              （2）生产模式
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-1-2-3-2'"
              >
                {{ dataCensus.produce_des }}
              </div>
            </div>

            <p class="text-indent">（3）销售模式</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <colgroup>
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
                <col width="12.5%" />
              </colgroup>
              <tbody>
                <tr>
                  <td>客户名称</td>
                  <td>商品名称</td>
                  <td>单价（元）</td>
                  <td>数量</td>
                  <td>数量单位</td>
                  <td>金额（万元）</td>
                  <td>合作年限</td>
                  <td>备注</td>
                </tr>
                <template v-if="dataBusinessSeller.length">
                  <tr v-for="(item, index) in dataBusinessSeller" :key="index">
                    <td>{{ item.sm_name }}</td>
                    <td>{{ item.sm_product }}</td>
                    <td>{{ item.unit }}</td>
                    <td>{{ item.current_year_amount }}</td>
                    <td>{{ item.unit }}</td>
                    <td>{{ item.current_year_total }}</td>
                    <td>{{ item.coo_years }}</td>
                    <td>{{ item.remark }}</td>
                  </tr>
                </template>
                <tr v-else>
                  <td v-for="i in 8" :key="`bSeller-empty-${i}`">-</td>
                </tr>
                <tr>
                  <td colspan="5" class="text-center">合计金额</td>
                  <td colspan="3" class="text-center">
                    {{ dataBusinessSellerFunds | pureUnit('万元') }}
                  </td>
                </tr>
              </tbody>
            </table>

            <div class="text-indent" id="anchor-1-2-3-3">
              销售模式分析：
              <div
                class="edit-eara"
                style="text-decoration: underline"
                v-anchor:report-edit.focus="'form-1-2-3-3'"
              >
                {{ dataCensus.sell_model_des }}
              </div>
            </div>

            <div class="text-indent" id="anchor-1-2-3-4">
              （4）技术保障：
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-2-3-4'">
                {{ dataCensus.tech_support_des }}
              </div>
            </div>

            <div class="text-indent" id="anchor-1-2-3-5">
              （5）三年规划：
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-2-3-5'">
                {{ dataCensus.future_plan }}
              </div>
            </div>

            <div class="text-indent" id="anchor-1-2-4">
              2.4 公司荣誉
              <div>{{ dataBaseInfo.en_honor_des }}</div>
            </div>

            <div class="text-indent" id="anchor-1-2-5">
              2.5 知识产权及经营许可
              <div>{{ dataBaseInfo.intellectual_property_des }}</div>
            </div>

            <p style="font-weight: bold" id="anchor-1-3">3. 公司管理</p>

            <p class="text-indent" id="anchor-1-3-1">3.1 组织架构</p>

            <chart-org-structure
              :customer-related-id="customerRelatedId"
              :img-type="true"
              :width="760"
              :customer-name="dataBase.customer_name"
            ></chart-org-structure>

            <p class="text-indent" id="anchor-1-3-2">3.2 核心团队</p>

            <!-- <p class="text-indent">（1）法人代表/经营者</p>

            <p class="text-indent">（2）主要技术人员</p>

            <p class="text-indent">（3）主要管理人员</p>

            <p class="text-indent">（4）参与经营的股东</p> -->

            <table
              class="table table-bordered table-striped table-border-black text-center mb-3"
              v-for="(p, index) in dataInfoSh"
              :key="`sh-${index}`"
            >
              <colgroup>
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
                <col width="11%" />
              </colgroup>
              <tr>
                <td colspan="9">
                  <span>{{ index + 1 }}、</span>
                  <span>{{ enumCorpType[p.is_corp] }}</span>
                  履历及期间积累情况
                </td>
              </tr>
              <tr>
                <td>姓名</td>
                <td>{{ p.real_name }}</td>
                <td>身份证号</td>
                <td colspan="3">{{ p.id_card || '-' }}</td>
                <td>持股比例</td>
                <td colspan="2">{{ p.sh_rate ? `${p.sh_rate}%` : '-' }}</td>
              </tr>
              <tr>
                <td>性别</td>
                <td>{{ enumSexType[p.sex] }}</td>
                <td>学历</td>
                <td colspan="3">{{ p.education ? enumEduType[p.education] : '-' }}</td>
                <td>联系电话</td>
                <td colspan="2">{{ p.mobile_no || '-' }}</td>
              </tr>
              <tr>
                <td>居住地址</td>
                <td colspan="5">{{ p.address || '-' }}</td>
                <td>婚姻状况</td>
                <td colspan="2">{{ p.marriage_status ? enumMarrType[p.marriage_status] : '-' }}</td>
              </tr>
              <tr>
                <td :rowspan="p.handEdu.length + 1">受教育经历</td>
                <td colspan="2">起止时间</td>
                <td>年龄阶段</td>
                <td colspan="2">教育机构</td>
                <td>专业</td>
                <td colspan="2">备注</td>
              </tr>
              <tr v-for="(edu, j) of p.handEdu" :key="`edu-${index}-${j}`">
                <td colspan="2">{{ edu.datePeriod }}</td>
                <td>{{ edu.age_inter || '-' }}</td>
                <td colspan="2">{{ edu.education_mech || '-' }}</td>
                <td>{{ edu.profession || '-' }}</td>
                <td colspan="2">{{ edu.remark || '-' }}</td>
              </tr>
              <tr>
                <td :rowspan="p.workExp.length + 1">工作经历</td>
                <td colspan="2">起止时间</td>
                <td>年龄阶段</td>
                <td colspan="2">工作单位</td>
                <td>职务</td>
                <td>资产积累(万元)</td>
                <td>大额开支</td>
              </tr>
              <tr v-for="(job, k) of p.workExp" :key="`work-${index}-${k}`">
                <td colspan="2">{{ job.datePeriod }}</td>
                <td>{{ job.age_inter || '-' }}</td>
                <td colspan="2">{{ job.work_unit || '-' }}</td>
                <td>{{ job.job || '-' }}</td>
                <td>{{ job.assets_total || '-' }}</td>
                <td>{{ job.assets_total || '-' }}</td>
              </tr>
            </table>

            <div class="text-indent" id="anchor-1-3-3">
              3.3 用工分析
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-3-3'">
                {{ dataCensus.management_model }}
              </div>
            </div>

            <p style="font-weight: bold" id="anchor-1-4">4. 经营资产信息</p>

            <p class="text-indent" id="anchor-1-4-1">4.1 基础条件</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>场地名称</td>
                  <td>性质</td>
                  <td>面积</td>
                  <td>权证情况</td>
                  <td>场地情况</td>
                  <td>起始时间</td>
                  <td>剩余年限</td>
                  <td>价值（万元）</td>
                  <td>地理位置</td>
                </tr>
                <template v-if="dataBusinessProduce.length">
                  <tr v-for="(item, i) in dataBusinessProduce" :key="`produce-${i}`">
                    <td>{{ item.produce_cond_name }}</td>
                    <td>{{ enumProduceNatureType[item.nature_type] }}</td>
                    <td>{{ item.area }}</td>
                    <td>{{ enumProductWarrantType[item.is_warrant] }}</td>
                    <td>{{ enumProductSitType[item.abc] }}</td>
                    <td>{{ $utils.dateFormat(item.start_date, 'yyyy.MM.dd') }}</td>
                    <td>{{ item.left_years }}</td>
                    <td>{{ item.left_value }}</td>
                    <td>{{ item.address_detail }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="j in 9" :key="`bp-empty-${j}`">-</td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-1-4-2">4.2 设备设施</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>类型名称</td>
                  <td>情况</td>
                  <td>规模</td>
                  <td>单位</td>
                  <td>备注</td>
                </tr>
                <template v-if="dataBusinessFacilities.length">
                  <tr v-for="(item, i) in dataBusinessFacilities" :key="`facilities-${i}`">
                    <td>{{ item.fac_name }}</td>
                    <td>{{ enumFacilityStatusType[item.sit_type] }}</td>
                    <td>{{ item.scale }}</td>
                    <td>{{ item.uscale }}</td>
                    <td>{{ item.remark }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="j in 5" :key="`bf-empty-${j}`">-</td>
                </tr>
              </tbody>
            </table>

            <table
              class="table table-bordered table-striped table-border-black mb-3"
              v-if="dataBase.farm_type === '2'"
            >
              <tbody>
                <tr>
                  <td>设备名称</td>
                  <td>类型</td>
                  <td>数量</td>
                  <td>单位</td>
                  <td>覆盖范围</td>
                </tr>
                <template v-if="dataBusinessFacProduce.length">
                  <tr v-for="(item, i) in dataBusinessFacProduce" :key="`fac-produce-${i}`">
                    <td>{{ item.fac_name }}</td>
                    <td>{{ enumFacType[item.fac_type] }}</td>
                    <td>{{ item.amount }}</td>
                    <td>{{ item.unit }}</td>
                    <td>{{ enumFacCoverType[item.coverage_type] }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="j in 5" :key="`bfp-empty-${j}`">-</td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-1-4-3">4.3 生物/存货资产</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>产品名称</td>
                  <td>基地类型</td>
                  <td>规模</td>
                  <td>库存</td>
                  <td>单价</td>
                  <td>价值</td>
                </tr>
                <template v-if="dataBioAssets.length">
                  <tr v-for="(item, i) in dataBioAssets" :key="`bio-assets-${i}`">
                    <td>{{ item.product_name }}</td>
                    <td>{{ item.base_type_name }}</td>
                    <td>{{ item.scale | pureUnit(item.uscale || '') }}</td>
                    <td>{{ item.store }}</td>
                    <td>{{ item.unit_price }}</td>
                    <td>{{ item.assets_value }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="j in 6" :key="`bio-empty-${j}`">-</td>
                </tr>
              </tbody>
            </table>

            <p style="font-weight: bold" id="anchor-1-5">5. 用电/水情况分析</p>

            <p class="text-indent" id="anchor-1-5-1">5.1 变化图标及用电明细同业对比图</p>

            <chart-power-use
              :img-type="true"
              :width="760"
              :customer-related-id="customerRelatedId"
            ></chart-power-use>

            <div class="text-indent" id="anchor-1-5-1-1">
              用电分析：
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-5-1-1'">
                {{ dataCensus.ele_analysis_des }}
              </div>
            </div>

            <p class="text-indent" id="anchor-1-5-2">5.2 变化图标及用水明细</p>

            <p class="text-indent"></p>

            <p class="text-indent">用水分析：</p>

            <p style="font-weight: bold" id="anchor-1-6">6. 公司竞争力</p>

            <div class="text-indent" id="anchor-1-6-1">
              6.1 优势分析
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-6-1'">
                {{ dataCensus.advantage_analysis }}
              </div>
            </div>

            <div class="text-indent" id="anchor-1-6-2">
              6.2 劣势分析
              <div class="edit-eara" v-anchor:report-edit.focus="'form-1-6-2'">
                {{ dataCensus.disadvantage_analysis }}
              </div>
            </div>

            <div class="text-indent" id="anchor-2-6">
              6.3 偿债能力分析
              <div class="edit-eara" v-anchor:report-edit.focus="'form-2-6'">
                {{ dataCensus.debt_analysis_des }}
              </div>
            </div>
          </div>

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 40px;
              "
              id="anchor-2"
            >
              二、财务分析
            </h2>

            <p style="font-weight: bold" id="anchor-2-1">1. 资金来源分析</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>资金来源</td>
                  <td>资金类别</td>
                  <td>资金用途</td>
                  <td>金额（元）</td>
                  <td>占比</td>
                  <td>备注</td>
                </tr>
                <template v-if="dataFinanceCapitalSource.length">
                  <tr v-for="(item, index) in dataFinanceCapitalSource" :key="`fcs-${index}`">
                    <td>{{ item.capital_source }}</td>
                    <td>{{ item.capital_type }}</td>
                    <td>{{ item.capital_use }}</td>
                    <td>{{ item.funds }}</td>
                    <td>{{ item.percent }}</td>
                    <td>{{ item.remark }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 6" :key="`fcs-empty-${k}`">-</td>
                </tr>
                <tr>
                  <td colspan="3">合计</td>
                  <td>{{ dataFinanceCapitalSourceTotal }}</td>
                  <td></td>
                  <td></td>
                </tr>
              </tbody>
            </table>

            <p style="font-weight: bold" id="anchor-2-2">2. 项目投入分析</p>

            <p class="text-indent" id="anchor-2-2-1">2.1 固定投入</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>项目</td>
                  <td>单位</td>
                  <td>单价（元）</td>
                  <td>数量</td>
                  <td>金额（万元）</td>
                  <td>备注</td>
                </tr>
                <template v-if="dataFinanceProjectInputSolid.length">
                  <tr v-for="(item, index) in dataFinanceProjectInputSolid" :key="`fpis-${index}`">
                    <td>{{ item.project_name }}</td>
                    <td>{{ item.uscale }}</td>
                    <td>{{ item.unit_price }}</td>
                    <td>{{ item.scale }}</td>
                    <td>{{ item.funds }}</td>
                    <td>{{ item.remark }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 6" :key="`fpis-empty-${k}`">-</td>
                </tr>
                <tr>
                  <td colspan="4">合计金额</td>
                  <td>{{ dataFinanceProjectInputSolidTotal }}</td>
                  <td></td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-2-2-2">2.2 流动投入</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>项目</td>
                  <td>单位</td>
                  <td>单价（元）</td>
                  <td>数量</td>
                  <td>金额（万元）</td>
                  <td>备注</td>
                </tr>
                <template v-if="dataFinanceProjectInputFlow.length">
                  <tr v-for="(item, index) in dataFinanceProjectInputFlow" :key="`fpif-${index}`">
                    <td>{{ item.project_name }}</td>
                    <td>{{ item.uscale }}</td>
                    <td>{{ item.unit_price }}</td>
                    <td>{{ item.scale }}</td>
                    <td>{{ item.funds }}</td>
                    <td>{{ item.remark }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 6" :key="`fpif-empty-${k}`">-</td>
                </tr>
                <tr>
                  <td colspan="4">合计金额</td>
                  <td>{{ dataFinanceProjectInputFlowTotal }}</td>
                  <td></td>
                </tr>
              </tbody>
            </table>

            <p style="font-weight: bold" id="anchor-2-3">3. 收入分析</p>

            <p class="text-indent" v-if="!chartInputOption">&nbsp;</p>

            <div v-else>
              <el-echarts
                theme="macarons"
                :height="300"
                :width="760"
                v-show="false"
                @onInit="onInitChartInput"
                :option="chartInputOption"
              ></el-echarts>

              <img height="300" class="w-100" :src="chartInputImgData" alt="" />
            </div>

            <p style="font-weight: bold" id="anchor-2-4">4. 经营流水分析</p>

            <table
              class="table table-bordered table-striped table-border-black mb-3"
              v-for="(item, index) in dataFinanceBackAccount"
              :key="`fba-${index}`"
            >
              <tbody>
                <tr>
                  <td colspan="4" class="text-center">
                    <span>{{ item.bank_account }} 的流水</span>
                    （银行：{{ item.bank_name }}，账号：{{ item.bank_no }}）
                  </td>
                </tr>
                <tr>
                  <td>日期</td>
                  <td>收入</td>
                  <td>支出</td>
                  <td>备注</td>
                </tr>
                <template v-if="item.bankFlow.length">
                  <tr v-for="(flow, j) in item.bankFlow" :key="`fba-d-${j}`">
                    <td>{{ flow.year }}.{{ flow.month }}</td>
                    <td>{{ flow.income }}</td>
                    <td>{{ flow.paid }}</td>
                    <td>{{ flow.remark }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 4" :key="`fba-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <div class="text-indent" id="anchor-2-4-1">
              <div class="edit-eara" v-anchor:report-edit.focus="'form-2-4-1'">
                {{ dataCensus.bank_flow_des }}
              </div>
            </div>

            <p style="font-weight: bold" id="anchor-2-5">5. 农业保险</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>保险公司名称</td>
                  <td>保险类型</td>
                  <td>险种</td>
                  <td>保额</td>
                  <td>保险价值</td>
                </tr>
                <template v-if="dataBusinessInsurance.length">
                  <tr v-for="(item, index) in dataBusinessInsurance" :key="`bi-${index}`">
                    <td>{{ item.insurance_com }}</td>
                    <td>{{ enumInsuranceType[item.insurance_type] }}</td>
                    <td>{{ item.insurance_class }}</td>
                    <td>{{ item.insurance_funds }}</td>
                    <td>{{ item.insurance_value }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 5" :key="`bi-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <div class="text-indent" id="anchor-2-5-1">
              <div class="edit-eara" v-anchor:report-edit.focus="'form-2-5-1'">
                {{ dataCensus.arg_insurance_des }}
              </div>
            </div>
          </div>

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 40px;
              "
              id="anchor-3"
            >
              三、信用分析
            </h2>

            <p style="font-weight: bold" id="anchor-3-1">1. 工商信用</p>

            <p class="text-indent" id="anchor-3-1-1">1.1 工商基本信息</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>统一社会信用代码</td>
                  <td colspan="2">{{ dataBase.register_no }}</td>
                  <td>登记状态</td>
                  <td>{{ dataBusinessInfo.register_status }}</td>
                </tr>
                <tr>
                  <td>类型</td>
                  <td colspan="2">{{ dataBusinessInfo.bussiness_type }}</td>
                  <td>法定代表人</td>
                  <td>{{ dataBase.corp_name }}</td>
                </tr>
                <tr>
                  <td>经营地址</td>
                  <td colspan="4">{{ dataBase.address }}</td>
                </tr>
                <tr>
                  <td>登记日期</td>
                  <td>{{ $utils.dateFormat(dataBaseInfo.established_date, 'yyyy.MM.dd') }}</td>
                  <td>成立日期</td>
                  <td colspan="2">
                    {{ $utils.dateFormat(dataBusinessInfo.approved_date, 'yyyy.MM.dd') }}
                  </td>
                </tr>
                <tr>
                  <td>登记机关</td>
                  <td colspan="2">{{ dataBusinessInfo.register_organ }}</td>
                  <td>注册资本</td>
                  <td>{{ dataBaseInfo.register_funds }}</td>
                </tr>
                <tr>
                  <td>经营范围</td>
                  <td colspan="4">{{ dataBase.bussiness_scope }}</td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-3-1-2">1.2 股权结构</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>股东名</td>
                  <td>股东类型</td>
                  <td>证号</td>
                  <td>认缴额</td>
                  <td>实缴额</td>
                  <td>持股比例</td>
                  <td>认缴期限</td>
                </tr>
                <template v-if="dataInfoSh.length">
                  <tr v-for="(item, index) in dataInfoSh" :key="`sh-${index}`">
                    <td>{{ item.real_name }}</td>
                    <td>{{ enumCorpType[item.is_corp] }}</td>
                    <td>{{ item.spouse_id_card }}</td>
                    <td>{{ item.invest_funds }}</td>
                    <td>{{ item.actual_funds }}</td>
                    <td>{{ item.sh_rate | pureUnit('%') }}</td>
                    <td>{{ item.invest_rate | timeDay }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 7" :key="`sh-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-3-1-3">1.3 工商变更信息</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td class="text-center">序号</td>
                  <td>变更事项</td>
                  <td>变更前内容</td>
                  <td>变更后内容</td>
                  <td>变更日期</td>
                </tr>
                <template v-if="dataBusinessChange.length">
                  <tr v-for="(item, index) in dataBusinessChange" :key="`bus-change-${index}`">
                    <td class="text-center">{{ index + 1 }}</td>
                    <td>{{ item.change_item }}</td>
                    <td>{{ item.before_content }}</td>
                    <td>{{ item.after_content }}</td>
                    <td>{{ item.change_date | timeDay }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 5" :key="`bus-change-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-3-1-4">1.4 股东关联公司</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>序号</td>
                  <td>公司名</td>
                  <td>注册地</td>
                  <td>注册资本</td>
                  <td>注册时间</td>
                  <td>法人</td>
                  <td>公司状态</td>
                </tr>
                <template v-if="dataBusinessAssoc.length">
                  <tr v-for="(item, index) in dataBusinessAssoc" :key="`assoc-${index}`">
                    <td class="text-center">{{ index + 1 }}</td>
                    <td>{{ item.assoc_entity_name }}</td>
                    <td>{{ item.register_address }}</td>
                    <td>{{ item.registered_capital }}</td>
                    <td>{{ item.registered_date | timeDay }}</td>
                    <td>{{ item.corp_name }}</td>
                    <td>{{ item.com_status }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 7" :key="`assoc-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <p style="font-weight: bold" id="anchor-3-2">2. 银行征信</p>

            <p class="text-indent" id="anchor-3-2-1">2.1 征信信息</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>借款人姓名</td>
                  <td>贷款/授信银行</td>
                  <td>贷款金额</td>
                  <td>余额</td>
                  <td>贷款期限</td>
                  <td>逾期次数</td>
                  <td>最大逾期金额</td>
                </tr>
                <template v-if="dataCredit.length">
                  <tr v-for="(item, index) in dataCredit" :key="`credit-${index}`">
                    <td>{{ item.shareholder_name }}</td>
                    <td>{{ item.loan_bank }}</td>
                    <td>{{ item.loan_funds }}</td>
                    <td>{{ item.loan_left }}</td>
                    <td>{{ item.end_date }}</td>
                    <td>{{ item.overdue_count }}</td>
                    <td>{{ item.overdue_amount }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 7" :key="`credit-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-3-2-2">2.2 征信分析</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>借款人姓名</td>
                  <td>贷款/授信银行</td>
                  <td>余额</td>
                  <td>逾期次数</td>
                  <td>最大逾期额</td>
                  <td>最大逾期时长</td>
                  <td>近3月次数</td>
                </tr>
                <template v-if="dataCredit.length">
                  <tr v-for="(item, index) in dataCredit" :key="`credit-${index}`">
                    <td>{{ item.shareholder_name }}</td>
                    <td>{{ item.loan_bank }}</td>
                    <td>{{ item.loan_left }}</td>
                    <td>{{ item.overdue_count }}</td>
                    <td>{{ item.overdue_amount }}</td>
                    <td>{{ item.overdue_duration }}</td>
                    <td>{{ item.latest_overdue_count }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 7" :key="`credit-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <p class="text-indent" id="anchor-3-2-3">2.3 对外担保情况</p>

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>担保对象</td>
                  <td>担保期限</td>
                  <td>担保额度</td>
                  <td>担保余额</td>
                </tr>
                <template v-if="dataWarrentForeign.length">
                  <tr v-for="(item, index) in dataWarrentForeign" :key="`warrent-${index}`">
                    <td>{{ item.warrant_object }}</td>
                    <td>{{ item.warrant_period }}</td>
                    <td>{{ item.warrant_funds }}</td>
                    <td>{{ item.warrant_left_funds }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 4" :key="`warrent-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <p style="font-weight: bold" id="anchor-3-3">3. 行政信息</p>

            <!-- <div class="text-indent"
                 id="anchor-3-3-1">
              <div class="edit-eara"
                   v-anchor:report-edit.focus="'form-3-3-1'">{{dataCensus.adm_des}}</div>
            </div> -->

            <table class="table table-bordered table-striped table-border-black mb-3">
              <tbody>
                <tr>
                  <td>许可证文件编号</td>
                  <td>许可证文件名称</td>
                  <td>有效期自</td>
                  <td>有效期至</td>
                  <td>许可机关</td>
                  <td>许可内容</td>
                </tr>
                <template v-if="dataAdminInfo.length">
                  <tr v-for="(item, index) in dataAdminInfo" :key="`admin-info-${index}`">
                    <td>{{ item.license_no }}</td>
                    <td>{{ item.license_name }}</td>
                    <td>{{ item.period_start }}</td>
                    <td>{{ item.period_end }}</td>
                    <td>{{ item.license_agency }}</td>
                    <!--<td>{{item.license_centent | substr}}</td>-->
                    <td style="max-width: 20rem">{{ item.license_centent | substr(100) }}</td>
                  </tr>
                </template>
                <tr v-else class="text-center">
                  <td v-for="k in 6" :key="`admin-info-empty-${k}`">-</td>
                </tr>
              </tbody>
            </table>

            <p style="font-weight: bold" id="anchor-3-4">4.司法信息</p>

            <div class="text-indent" id="anchor-3-4-1">
              <div>4.1 司法信息数</div>
              <div class="edit-eara" v-anchor:report-edit.focus="'form-3-4-1'">
                {{ dataCensus.jud_des }}
              </div>
            </div>

            <div class="text-indent" id="anchor-3-4-2">
              <div>4.2 涉诉信息数</div>
              <div class="edit-eara" v-anchor:report-edit.focus="'form-3-4-2'">
                {{ dataCensus.involved_des }}
              </div>
            </div>
          </div>

          <div style="page-break-after: always">
            <h2
              style="
                text-align: center;
                margin-top: 80px;
                font-size: 2.5rem;
                font-weight: bold;
                font-family: SimHei;
                margin-bottom: 40px;
              "
              id="anchor-4"
            >
              四、大数据评级及授信建议有关说明
            </h2>

            <p style="font-weight: bold">1. 大数据信用评分</p>

            <div class="text-indent" id="anchor-4-1">
              <div class="edit-eara" v-anchor:report-edit.focus="'form-4-1'">
                {{ dataCensus.census_opinion }}
              </div>
            </div>

            <p class="text-indent">
              评级得分：{{ dataScoreApiScore }} 分，对应等级：{{ dataScoreApiLevel }} 级
            </p>

            <div style="line-height: 1.5; font-size: 1.5rem; margin-bottom: 1rem">
              <div class="d-flex">
                <div style="width: 50px">&nbsp;</div>
                <div style="flex: 1; position: relative; height: 65px">
                  <div
                    style="position: absolute; top: 0"
                    :style="{ left: `${+dataScoreApiScore - 0.5}%` }"
                  >
                    <div>{{ dataScoreApiScore }}</div>
                    <i class="fa fa-long-arrow-down"></i>
                  </div>
                </div>
              </div>
              <div class="d-flex">
                <div style="width: 50px">分值</div>
                <div style="flex: 1; display: flex">
                  <span
                    v-for="(s, i) in scoreLevel"
                    :key="i"
                    style="flex: 1; text-align: right; padding-right: 5px"
                    :style="{ backgroundColor: s.color }"
                  >
                    {{ s.score }}
                  </span>
                </div>
              </div>
              <div class="d-flex">
                <div style="width: 50px">等级</div>
                <div
                  style="
                    flex: 1;
                    display: flex;
                    border-left: 1px solid #333;
                    border-top: 1px solid #333;
                  "
                >
                  <span
                    v-for="(d, j) in levelDivide"
                    :key="j"
                    style="
                      text-align: center;
                      border-right: 1px solid #333;
                      border-bottom: 1px solid #333;
                    "
                    :style="{ flex: d.area }"
                  >
                    {{ d.label }}
                  </span>
                </div>
              </div>
            </div>

            <chart-market-fund
              :img-type="true"
              :width="760"
              :customer-related-id="customerRelatedId"
            ></chart-market-fund>

            <div class="text-indent">
              <span>授信建议金额为：</span>
              &nbsp;
              <span
                class="edit-eara d-inline-block px-2 text-center"
                style="text-indent: 0"
                v-anchor:report-edit.focus="'form-conc-4-1'"
              >
                {{ dataCensus.eva_funds }}
              </span>
              <span>&nbsp;万元</span>
            </div>

            <p style="font-weight: bold" id="anchor-4-2">2. 联系人</p>

            <p class="text-indent">铜仁市农业信贷担保有限公司-xxx：13900000000</p>

            <p class="text-indent">公司…………………………联系人-xxx:13800000000</p>

            <p class="text-indent">
              本报告于{{
                startValidityPeriod
              }}经铜仁市农担公司风险委员会批准（大数据机构）。有效期自{{ startValidityPeriod }}至{{
                endValidityPeriod
              }}。
            </p>

            <div style="text-align: right; margin-bottom: 1rem">
              <span>调查小组：</span>
              <div style="display: inline-block; width: 100px; border-bottom: 1px solid #333">
                &nbsp;
              </div>
            </div>
            <div style="text-align: right; margin-bottom: 1rem">
              <span>报告制作小组：</span>
              <div style="display: inline-block; width: 100px; border-bottom: 1px solid #333">
                &nbsp;
              </div>
            </div>
            <div style="text-align: right; margin-bottom: 1rem">
              <span>审核人：</span>
              <div style="display: inline-block; width: 100px; border-bottom: 1px solid #333">
                &nbsp;
              </div>
            </div>
            <p style="text-align: right">&nbsp;&nbsp;&nbsp;年&nbsp;月&nbsp;日</p>
          </div>
        </div>
      </div>
    </div>

    <div style="flex: 1; min-width: 360px" v-show="!viewMode">
      <div class="d-flex justify-content-between mb-1">
        <div>
          <button type="button" class="btn btn-sm btn-text">&nbsp;</button>
        </div>
        <h5 class="text-muted m-0">编辑</h5>
      </div>
      <div class="card scroll-y" :style="{ height: `${height}px` }" id="report-edit">
        <div class="card-body">
          <p class="text-muted">目录</p>

          <button
            type="button"
            class="btn btn-sm btn-outline-secondary ml-3 mb-3"
            @click="menuVisible = true"
          >
            页码设置
          </button>

          <p class="text-muted">大数据信用评分风险提示</p>

          <div class="form-group ml-3">
            <label for="form-conc-3-1">信用风险</label>
            <textarea
              class="form-control"
              id="form-conc-3-1"
              placeholder="信用风险"
              v-model="dataCensus.credit_risk_analysis"
              v-focus="'anchor-conc-3-1'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-conc-3-2">偿债风险</label>
            <textarea
              class="form-control"
              id="form-conc-3-2"
              placeholder="偿债风险"
              v-model="dataCensus.debt_risk_analysis"
              v-focus="'anchor-conc-3-2'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-conc-4-1">授信评估额度</label>
            <div class="input-group">
              <input
                type="number"
                min="0"
                step="any"
                class="form-control"
                id="form-conc-4-1"
                placeholder="授信评估额度"
                v-model="dataCensus.eva_funds"
                v-focus="'anchor-conc-4-1'"
              />
              <div class="input-group-append">
                <div class="input-group-text">万元</div>
              </div>
            </div>
          </div>

          <div class="form-group ml-3">
            <label for="form-conc-4-2">理由说明</label>
            <textarea
              class="form-control"
              id="form-conc-4-2"
              placeholder="偿债风险"
              v-model="dataCensus.eva_reason"
              v-focus="'anchor-conc-4-2'"
            ></textarea>
          </div>

          <p class="text-muted">1.1 PEST分析</p>

          <div class="form-group ml-3">
            <label for="form-1-1-p">P分析</label>
            <textarea
              class="form-control"
              id="form-1-1-p"
              v-model="dataPest.p"
              rows="4"
              placeholder="请输入P分析"
              v-focus="'anchor-1-1-1-p'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-1-e">E分析</label>
            <textarea
              class="form-control"
              id="form-1-1-e"
              rows="4"
              v-model="dataPest.e"
              placeholder="请输入E分析"
              v-focus="'anchor-1-1-1-e'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-1-s">S分析</label>
            <textarea
              class="form-control"
              id="form-1-1-s"
              rows="4"
              v-model="dataPest.s"
              placeholder="请输入S分析"
              v-focus="'anchor-1-1-1-s'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-1-t">T分析</label>
            <textarea
              class="form-control"
              id="form-1-1-t"
              rows="4"
              v-model="dataPest.t"
              placeholder="请输入T分析"
              v-focus="'anchor-1-1-1-t'"
            ></textarea>
          </div>

          <p class="text-muted">1.2 行业发展状况分析</p>

          <div class="card ml-3 mb-3" v-for="(item, index) in dataIndustryAnalysis" :key="index">
            <div class="card-body">
              <div class="form-group">
                <label>主营产品</label>
                <select-product-cate
                  v-model="item.category_code"
                  @change="(val, name) => onIndustryAnalysisMainChange(index, val, name)"
                  el-css="w-100"
                ></select-product-cate>
              </div>

              <div class="form-group">
                <label>主营产品价格趋势图</label>
                <el-checkbox-group v-model="item.price_analysis_dim">
                  <el-checkbox
                    v-for="(val, key) in dataIndustryAnalysisChartTypeEnum"
                    :key="key"
                    :label="key"
                  >
                    {{ val }}
                  </el-checkbox>
                </el-checkbox-group>
              </div>

              <div class="form-group">
                <label>主营产品行情分析</label>
                <textarea
                  class="form-control"
                  :id="`form-1-1-2-1-${index}`"
                  rows="4"
                  v-model="item.price_analysis"
                  placeholder="请输入分析"
                  v-focus="`anchor-1-1-2-1-${index}`"
                ></textarea>
              </div>

              <div class="form-group">
                <label>原材料</label>
                <select-product-cate
                  v-model="item.material_category_code"
                  @change="(val, name) => onIndustryAnalysisMaterialChange(index, val, name)"
                  el-css="w-100"
                ></select-product-cate>
              </div>

              <div class="form-group">
                <label for="form-1-2">主营产品原材料价格趋势图</label>
                <el-checkbox-group v-model="item.material_analysis_dim">
                  <el-checkbox
                    v-for="(val, key) in dataIndustryAnalysisChartTypeEnum"
                    :key="key"
                    :label="key"
                  >
                    {{ val }}
                  </el-checkbox>
                </el-checkbox-group>
              </div>

              <div class="form-group">
                <label>原材料行情分析</label>
                <textarea
                  class="form-control"
                  :id="`form-1-1-2-2-${index}`"
                  rows="4"
                  v-model="item.material_analysis"
                  placeholder="请输入分析"
                  v-focus="`anchor-1-1-2-2-${index}`"
                ></textarea>
              </div>

              <div class="btn-list">
                <button
                  class="btn btn-sm btn-outline-secondary"
                  @click="updateIndustryAnalysis(item)"
                >
                  <i class="fa fa-save"></i>
                  保存
                </button>
                <button
                  class="btn btn-sm btn-outline-secondary float-right"
                  @click="deleteIndustryAnalysis(item.datum_customer_industry_analysis_id)"
                >
                  <i class="fa fa-trash"></i>
                  删除
                </button>
              </div>
            </div>
          </div>

          <button class="btn btn-sm btn-outline-secondary ml-3 mb-3" @click="addIndustryAnalysis()">
            <i class="fa fa-plus"></i>
            添加产品行情分析
          </button>

          <div class="form-group ml-3">
            <label for="form-1-1-3-1">区域内行业地位分析</label>
            <textarea
              class="form-control"
              id="form-1-1-3-1"
              v-model="dataPositAnalysis.rank_analysis"
              rows="4"
              placeholder="请输入区域内行业地位分析"
              v-focus="'anchor-1-1-3-1'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-1-3-2">区县产业集中度情况分析</label>
            <textarea
              class="form-control"
              id="form-1-1-3-2"
              v-model="dataPositAnalysis.concent_analysis"
              rows="4"
              placeholder="请输入区县产业集中度情况分析"
              v-focus="'anchor-1-1-3-2'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-1-3-3">乡镇产业集中度情况分析</label>
            <textarea
              class="form-control"
              id="form-1-1-3-3"
              v-model="dataPositAnalysis.concent_analysis_vil"
              rows="4"
              placeholder="请输入乡镇产业集中度情况分析"
              v-focus="'anchor-1-1-3-3'"
            ></textarea>
          </div>

          <p class="text-muted">2. 经营分析</p>

          <div class="form-group ml-3">
            <label for="form-1-2-1">历史沿革</label>
            <textarea
              class="form-control"
              id="form-1-2-1"
              v-model="dataCensus.business_history"
              rows="4"
              placeholder="请输入历史沿革"
              v-focus="'anchor-1-2-1'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-2-2">经营业务</label>
            <textarea
              class="form-control"
              id="form-1-2-2"
              v-model="dataCensus.business_des"
              rows="4"
              placeholder="请输入经营模式"
              v-focus="'anchor-1-2-2'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-2-3">经营模式</label>
            <textarea
              class="form-control"
              id="form-1-2-3"
              v-model="dataCensus.business_model"
              rows="4"
              placeholder="请输入经营模式"
              v-focus="'anchor-1-2-3'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-2-3-1">采购模式分析</label>
            <textarea
              class="form-control"
              id="form-1-2-3-1"
              v-model="dataCensus.purchase_model_des"
              rows="4"
              placeholder="请输入采购模式分析"
              v-focus="'anchor-1-2-3-1'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-2-3-2">生产模式</label>
            <textarea
              class="form-control"
              id="form-1-2-3-2"
              v-model="dataCensus.produce_des"
              rows="4"
              placeholder="请输入生产模式"
              v-focus="'anchor-1-2-3-2'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-2-3-3">销售模式分析</label>
            <textarea
              class="form-control"
              id="form-1-2-3-3"
              v-model="dataCensus.sell_model_des"
              rows="4"
              placeholder="请输入销售模式分析"
              v-focus="'anchor-1-2-3-3'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-2-3-4">技术保障</label>
            <textarea
              class="form-control"
              id="form-1-2-3-4"
              v-model="dataCensus.tech_support_des"
              rows="4"
              placeholder="请输入技术保障"
              v-focus="'anchor-1-2-3-4'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-2-3-5">三年规划</label>
            <textarea
              class="form-control"
              id="form-1-2-3-5"
              v-model="dataCensus.future_plan"
              rows="4"
              placeholder="请输入三年规划"
              v-focus="'anchor-1-2-3-5'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-3-3">用工分析</label>
            <textarea
              class="form-control"
              id="form-1-3-3"
              v-model="dataCensus.management_model"
              rows="4"
              placeholder="请输入用工分析"
              v-focus="'anchor-1-3-3'"
            ></textarea>
          </div>

          <p class="text-muted">4.3 生物/存货资产</p>

          <div class="ml-3 mb-3">
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>产品名称</td>
                  <td>基地类型</td>
                  <td>价值</td>
                  <td>操作</td>
                </tr>
                <tr v-for="(item, i) in dataBioAssets" :key="`bio-assets-edit-${i}`">
                  <td>{{ item.product_name }}</td>
                  <td>{{ item.base_type_name }}</td>
                  <td>{{ item.assets_value }}</td>
                  <td class="btn-list">
                    <button class="btn btn-sm btn-outline-secondary" @click="onBioEdit(item)">
                      <i class="fa fa-edit"></i>
                      修改
                    </button>
                    <button class="btn btn-sm btn-outline-secondary" @click="onBioDelete(item)">
                      <i class="fa fa-trash"></i>
                      删除
                    </button>
                  </td>
                </tr>
              </tbody>
            </table>
            <button class="btn btn-sm btn-outline-secondary" @click="bioVisible = true">
              <i class="fa fa-plus"></i>
              添加生物/存货资产
            </button>
          </div>

          <p class="text-muted">5. 用电/水情况分析</p>

          <div class="form-group ml-3">
            <label for="form-1-5-1-1">用电分析</label>
            <textarea
              class="form-control"
              id="form-1-5-1-1"
              v-model="dataCensus.ele_analysis_des"
              rows="4"
              placeholder="请输入用工分析"
              v-focus="'anchor-1-5-1-1'"
            ></textarea>
          </div>

          <p class="text-muted">公司竞争力</p>

          <div class="form-group ml-3">
            <label for="form-1-6-1">6.1 优势分析</label>
            <textarea
              class="form-control"
              id="form-1-6-1"
              v-model="dataCensus.advantage_analysis"
              rows="4"
              placeholder="请输入用工分析"
              v-focus="'anchor-1-6-1'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-1-6-2">6.2 劣势分析</label>
            <textarea
              class="form-control"
              id="form-1-6-2"
              v-model="dataCensus.disadvantage_analysis"
              rows="4"
              placeholder="请输入用工分析"
              v-focus="'anchor-1-6-2'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-2-6">6.3 偿债能力分析</label>
            <textarea
              class="form-control"
              id="form-2-6"
              v-model="dataCensus.debt_analysis_des"
              rows="4"
              placeholder="请输入偿债能力分析"
              v-focus="'anchor-2-6'"
            ></textarea>
          </div>

          <h5>二、账务分析</h5>

          <div class="form-group ml-3">
            <label for="form-2-4-1">4. 经营流水分析</label>
            <textarea
              class="form-control"
              id="form-2-4-1"
              v-model="dataCensus.bank_flow_des"
              rows="4"
              placeholder="请输入经营流水分析"
              v-focus="'anchor-2-4-1'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-2-5-1">5. 农业保险</label>
            <textarea
              class="form-control"
              id="form-2-5-1"
              v-model="dataCensus.arg_insurance_des"
              rows="4"
              placeholder="请输入农业保险"
              v-focus="'anchor-2-5-1'"
            ></textarea>
          </div>

          <h5>三、信用分析</h5>

          <p class="text-muted">1.1 工商基本信息</p>

          <div class="form-group ml-3">
            <label for="form-3-1-1-1">统一信用代码</label>
            <input
              class="form-control"
              type="text"
              id="form-3-1-1-1"
              v-model="dataBusinessInfo.register_no"
              placeholder="请输入统一信用代码"
              v-focus="'anchor-3-1-1'"
            />
          </div>

          <div class="form-group ml-3">
            <label for="form-3-1-1-2">登记状态</label>
            <input
              class="form-control"
              type="text"
              id="form-3-1-1-2"
              v-model="dataBusinessInfo.register_status"
              placeholder="请输入登记状态"
              v-focus="'anchor-3-1-1'"
            />
          </div>

          <div class="form-group ml-3">
            <label for="form-3-1-1-3">类型</label>
            <input
              class="form-control"
              type="text"
              id="form-3-1-1-3"
              v-model="dataBusinessInfo.bussiness_type"
              placeholder="请输入类型"
              v-focus="'anchor-3-1-1'"
            />
          </div>

          <div class="form-group ml-3">
            <label for="form-3-1-1-4">成立日期</label>
            <input
              class="form-control"
              type="date"
              id="form-3-1-1-4"
              v-model="dataBusinessInfo.approved_date"
              placeholder="请输入成立日期"
              v-focus="'anchor-3-1-1'"
            />
          </div>

          <div class="form-group ml-3">
            <label for="form-3-1-1-5">登记机关</label>
            <input
              class="form-control"
              type="text"
              id="form-3-1-1-5"
              v-model="dataBusinessInfo.register_organ"
              placeholder="请输入登记机关"
              v-focus="'anchor-3-1-1'"
            />
          </div>

          <p class="text-muted">1.3 工商变更信息</p>

          <div class="ml-3 mb-3">
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>变更事项</td>
                  <td>变更后内容</td>
                  <td>操作</td>
                </tr>
                <tr v-for="(item, i) in dataBusinessChange" :key="`bus-change-edit-${i}`">
                  <td>{{ item.change_item }}</td>
                  <td>{{ item.after_content }}</td>
                  <td class="btn-list">
                    <button class="btn btn-sm btn-outline-secondary" @click="onBusChangeEdit(item)">
                      <i class="fa fa-edit"></i>
                      修改
                    </button>
                    <button
                      class="btn btn-sm btn-outline-secondary"
                      @click="onBusChangeDelete(item)"
                    >
                      <i class="fa fa-trash"></i>
                      删除
                    </button>
                  </td>
                </tr>
              </tbody>
            </table>
            <button class="btn btn-sm btn-outline-secondary" @click="busChangeVisible = true">
              <i class="fa fa-plus"></i>
              添加变更信息
            </button>
          </div>

          <p class="text-muted">1.4 股东关联公司</p>

          <div class="ml-3 mb-3">
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>公司名</td>
                  <td>法人</td>
                  <td>操作</td>
                </tr>
                <tr v-for="(item, i) in dataBusinessAssoc" :key="`bus-change-edit-${i}`">
                  <td>{{ item.assoc_entity_name }}</td>
                  <td>{{ item.corp_name }}</td>
                  <td class="btn-list">
                    <button class="btn btn-sm btn-outline-secondary" @click="onBusAssocEdit(item)">
                      <i class="fa fa-edit"></i>
                      修改
                    </button>
                    <button
                      class="btn btn-sm btn-outline-secondary"
                      @click="onBusAssocDelete(item)"
                    >
                      <i class="fa fa-trash"></i>
                      删除
                    </button>
                  </td>
                </tr>
              </tbody>
            </table>
            <button class="btn btn-sm btn-outline-secondary" @click="busAssocVisible = true">
              <i class="fa fa-plus"></i>
              添加股东关联公司
            </button>
          </div>

          <p class="text-muted">3. 行政信息</p>

          <!-- <div class="form-group ml-3">
            <textarea class="form-control"
                      rows="4"
                      id="form-3-3"
                      v-model="dataCensus.adm_des"
                      placeholder="请输入行政信息"
                      v-focus="'anchor-3-3'"></textarea>
          </div> -->

          <div class="ml-3 mb-3">
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>许可证文件编号</td>
                  <td>许可证文件名称</td>
                  <td>操作</td>
                </tr>
                <tr v-for="(item, i) in dataAdminInfo" :key="`admin-info-edit-${i}`">
                  <td>{{ item.license_no }}</td>
                  <td>{{ item.license_name }}</td>
                  <td class="btn-list">
                    <button class="btn btn-sm btn-outline-secondary" @click="onAdminInfoEdit(item)">
                      <i class="fa fa-edit"></i>
                      修改
                    </button>
                    <button
                      class="btn btn-sm btn-outline-secondary"
                      @click="onAdminInfoDelete(item)"
                    >
                      <i class="fa fa-trash"></i>
                      删除
                    </button>
                  </td>
                </tr>
              </tbody>
            </table>
            <button class="btn btn-sm btn-outline-secondary" @click="adminInfoVisible = true">
              <i class="fa fa-plus"></i>
              添加行政信息
            </button>
          </div>

          <p class="text-muted">4. 司法信息</p>

          <div class="form-group ml-3">
            <label for="form-3-4-1">司法信息数</label>
            <textarea
              class="form-control"
              rows="4"
              id="form-3-4-1"
              v-model="dataCensus.jud_des"
              placeholder="请输入司法信息数"
              v-focus="'anchor-3-4-1'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-3-4-2">涉诉信息数</label>
            <textarea
              class="form-control"
              rows="4"
              id="form-3-4-2"
              v-model="dataCensus.involved_des"
              placeholder="请输入涉诉信息数"
              v-focus="'anchor-3-4-2'"
            ></textarea>
          </div>

          <div class="form-group ml-3">
            <label for="form-4-1">授信建议量的有关说明</label>
            <textarea
              class="form-control"
              rows="4"
              id="form-4-1"
              v-model="dataCensus.census_opinion"
              placeholder="请输入授信建议量的有关说明"
              v-focus="'anchor-4-1'"
            ></textarea>
          </div>
        </div>
      </div>
    </div>

    <el-dialog
      :visible.sync="menuVisible"
      title="页码设置"
      :close-on-click-modal="false"
      class="dialog-sm"
      top="30px"
    >
      <div class="btn-list mb-3">
        <button type="button" class="btn btn-sm btn-outline-secondary" @click="onSaveMenu">
          <i class="fa fa-save"></i>
          保存
        </button>
        <button type="button" class="btn btn-sm btn-outline-secondary" @click="menuVisible = false">
          <i class="fa fa-window-close-o"></i>
          取消
        </button>
        <button
          type="button"
          v-show="false"
          class="btn btn-sm btn-outline-secondary"
          @click="resetMenu"
        >
          <i class="fa fa-wrench"></i>
          重置
        </button>
      </div>

      <ul class="list-unstyled">
        <li v-for="(menu, index) in dataMenu" :key="index">
          <div class="d-flex align-items-center mb-1">
            <div :class="{ 'pl-3': menu.dir_lever === '3' }">{{ menu.dir_name }}</div>
            <div class="flex-grow-1 d-flex align-items-center px-1">
              <div style="border-bottom: 1px dotted #333; flex: 1"></div>
            </div>
            <div>
              <input
                type="number"
                min="1"
                step="1"
                class="form-control form-control-sm"
                style="width: 60px"
                v-model="menu.dir_page_num"
              />
            </div>
          </div>
        </li>
      </ul>
    </el-dialog>

    <el-dialog
      :visible.sync="bioVisible"
      title="编辑生物/存货资产"
      class="dialog-sm"
      width="400px"
      :before-close="beforeBioClose"
      top="30px"
    >
      <el-form label-width="80px">
        <el-form-item label="产品名称">
          <el-input v-model="bioSelect.product_name"></el-input>
        </el-form-item>
        <el-form-item label="基地类型">
          <select-base-type
            v-model="bioSelect.base_type"
            @change="onBioBaseTypeChange"
          ></select-base-type>
        </el-form-item>
        <el-form-item label="规模">
          <el-input v-model="bioSelect.scale"></el-input>
        </el-form-item>
        <el-form-item label="库存">
          <el-input v-model="bioSelect.store"></el-input>
        </el-form-item>
        <el-form-item label="单位">
          <el-input v-model="bioSelect.uscale"></el-input>
        </el-form-item>
        <el-form-item label="单价">
          <el-input v-model="bioSelect.unit_price"></el-input>
        </el-form-item>
        <el-form-item label="价值">
          <el-input v-model="bioSelect.assets_value"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onBioSave">保存</el-button>
          <el-button @click="beforeBioClose">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog
      :visible.sync="busChangeVisible"
      :close-on-click-modal="false"
      title="编辑工商变更信息"
      class="dialog-sm"
      width="600px"
      :before-close="beforeBusChangeClose"
      top="30px"
    >
      <el-form label-width="100px">
        <el-form-item label="变更事项">
          <el-input v-model="busChangeSelect.change_item"></el-input>
        </el-form-item>
        <el-form-item label="变更前内容">
          <el-input v-model="busChangeSelect.before_content"></el-input>
        </el-form-item>
        <el-form-item label="变更后内容">
          <el-input v-model="busChangeSelect.after_content"></el-input>
        </el-form-item>
        <el-form-item label="变更日期">
          <el-date-picker
            v-model="busChangeSelect.change_date"
            type="date"
            class="w-100"
            value-format="yyyy-MM-dd"
            placeholder="选择变更日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onBusChangeSave">保存</el-button>
          <el-button @click="beforeBusChangeClose">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog
      :visible.sync="busAssocVisible"
      :close-on-click-modal="false"
      title="编辑股东关联公司"
      class="dialog-sm"
      width="600px"
      :before-close="beforeBusAssocClose"
      top="30px"
    >
      <el-form label-width="100px">
        <el-form-item label="公司名">
          <el-input v-model="busAssocSelect.assoc_entity_name"></el-input>
        </el-form-item>
        <el-form-item label="注册地">
          <el-input v-model="busAssocSelect.register_address"></el-input>
        </el-form-item>
        <el-form-item label="注册资本">
          <el-input v-model="busAssocSelect.registered_capital"></el-input>
        </el-form-item>
        <el-form-item label="注册时间">
          <el-date-picker
            v-model="busAssocSelect.registered_date"
            type="date"
            class="w-100"
            value-format="yyyy-MM-dd"
            placeholder="选择注册时间"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="法人">
          <el-input v-model="busAssocSelect.corp_name"></el-input>
        </el-form-item>
        <el-form-item label="公司状态">
          <el-input v-model="busAssocSelect.com_status"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onBusAssocSave">保存</el-button>
          <el-button @click="beforeBusAssocClose">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog
      :visible.sync="adminInfoVisible"
      :close-on-click-modal="false"
      title="编辑行政信息"
      class="dialog-sm"
      width="680px"
      :before-close="beforeAdminInfoClose"
      top="30px"
    >
      <el-form
        label-width="120px"
        :model="adminInfoSelect"
        :rules="{
          license_no: [{ required: true, message: '请输入许可证文件编号', trigger: 'blur' }],
        }"
        ref="adminInfoForm"
      >
        <el-form-item label="许可证文件编号" prop="license_no">
          <el-input v-model="adminInfoSelect.license_no"></el-input>
        </el-form-item>
        <el-form-item label="许可证文件名称">
          <el-input v-model="adminInfoSelect.license_name"></el-input>
        </el-form-item>
        <el-form-item label="有效期">
          <div class="d-flex">
            <el-date-picker
              v-model="adminInfoSelect.period_start"
              type="date"
              class="flex-grow-1"
              value-format="yyyy-MM-dd"
              placeholder="有效期自"
            ></el-date-picker>
            <span>至</span>
            <el-date-picker
              v-model="adminInfoSelect.period_end"
              type="date"
              class="flex-grow-1"
              value-format="yyyy-MM-dd"
              placeholder="有效期至"
            ></el-date-picker>
          </div>
        </el-form-item>
        <el-form-item label="许可机关">
          <el-input v-model="adminInfoSelect.license_agency"></el-input>
        </el-form-item>
        <el-form-item label="许可内容">
          <el-input type="textarea" v-model="adminInfoSelect.license_centent"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onAdminInfoSave">保存</el-button>
          <el-button @click="beforeAdminInfoClose">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import { scrollTo, calcSpan } from '@/common/plugins/tools/common'
import { fixed, formatLine } from '@/common/plugins/tools/format'
import { printHtml, domAddClass, domRemoveClass } from '@vimi/utils-tool'

import ChartMarketAverage from '@/credit/components/chart/ChartMarketAverage'
import ChartMarketScale from '@/credit/components/chart/ChartMarketScale'
import ChartMarketArea from '@/credit/components/chart/ChartMarketArea'
import ChartMarketFund from '@/credit/components/chart/ChartMarketFund'
import ChartPowerUse from '@/credit/components/chart/ChartPowerUse'
import ChartOrgStructure from '@/credit/components/chart/ChartOrgStructure'
import SelectProductCate from '@/components/select/SelectProductCate'
import SelectBaseType from '@/components/select/SelectBaseType'
import {
  enumFarmType,
  enumCorpType,
  enumSexType,
  enumEduType,
  enumMarrType,
  enumProduceNatureType,
  enumProductWarrantType,
  enumProductSitType,
  enumFacilityStatusType,
  enumFacType,
  enumFacCoverType,
  enumInsuranceType,
} from '@/credit/plugins/enum'

const CREDIT_SERVER = 'credit'

export default {
  components: {
    // quillEditor,
    ChartMarketAverage,
    ChartMarketScale,
    ChartMarketArea,
    ChartMarketFund,
    ChartPowerUse,
    ChartOrgStructure,
    SelectProductCate,
    SelectBaseType,
  },
  props: {
    viewMode: Boolean,
    relatedId: String,
  },
  data() {
    return {
      enumFarmType,
      enumCorpType,
      enumSexType,
      enumEduType,
      enumMarrType,
      enumProduceNatureType,
      enumProductWarrantType,
      enumProductSitType,
      enumFacilityStatusType,
      enumFacType,
      enumFacCoverType,
      enumInsuranceType,
      ratingStatus: 1,
      height: 800,
      customerRelatedId: this.relatedId,
      loading: false,
      // 企业信息
      dataBase: {}, // 关联基本信息
      dataBaseInfo: {}, // 企业基本信息
      // 人员信息
      dataInfoSh: [], // 股东信息（包括法人与配偶）
      dataInfoLegal: {}, // 法人信息
      dataInfoSpouse: {}, // 配偶信息
      dataInfoControl: {}, // 实际控制人
      // 产品信息
      dataProduct: [], // 所有产品
      dataProductMain: {}, // 主导产业
      // 行业发展状况分析
      // industryAnalysisId: '',
      dataIndustryAnalysis: [],
      // dataIndustryAnalysis: {
      //   customer_related_id: '',
      //   category_code: '',
      //   material_category_code: '',
      //   price_analysis_dim: ['year'],
      //   material_analysis_dim: ['year']
      // },
      // dataIndustryAnalysisSolid: {},
      dataIndustryAnalysisChartTypeEnum: {
        year: '近7年',
        quarter: '近4个季度',
        month: '近一年',
        day: '近30天',
      },
      // 征信
      dataCredit: [], // 所有征信
      // dataCreditCompany: {},  // 企业征信
      // dataCreditLegal: {},    // 股东征信
      // dataCreditSpouse: {},   // 配偶征信
      // 评分
      dataScoreApiScore: 0,
      dataScoreApiLevel: '',
      dataScoreLoseList: [],
      dataScoreFirstList: [],
      // 账务信息
      dataFinanceCapitalSource: [], // 资金来源明细
      dataFinanceCapitalSourceTotal: 0,
      dataFinanceProjectInputSolid: [], // 固定资金投入明细
      dataFinanceProjectInputSolidTotal: 0,
      dataFinanceProjectInputFlow: [], // 流动资金投入明细
      dataFinanceProjectInputFlowTotal: 0,
      dataFunds: {
        inputs: 0, // 累计投入
        debt: 0, // 累积负债
        funds: 0, // 累积自有资金
        percent: '', // 自有资金占比
      },
      // 收入分析图表
      chartInputOption: null,
      chartInputImgData: '',
      chartInput: null,
      // 报告中的内容
      dataReport: {},
      dataReportSolid: {},
      // 尽调报告
      censusId: '',
      dataCensus: {
        customer_id: '',
        customer_related_id: '',
        census_number: '',
        credit_risk_analysis: '', // 信用风险
        debt_risk_analysis: '', // 偿债风险
        eva_funds: '', // 评估金额
        eva_reason: '', // 理由说明
        business_history: '', // 历史沿革
        business_des: '', // 经营业务
        business_model: '', // 经营模式
        future_plan: '', // 三年规划
        purchase_model_des: '', // 采购模式分析
        produce_des: '', // 生产模式分析
        sell_model_des: '', // 销售模式分析
        tech_support_des: '', // 技术保障
        management_model: '', // 用工分析
        ele_analysis_des: '', // 用电分析
        advantage_analysis: '', // 优势分析
        disadvantage_analysis: '', // 劣势分析
        bank_flow_des: '', // 经营流水说明
        arg_insurance_des: '', // 农业保险说明
        debt_analysis_des: '', // 偿债能力分析
        adm_des: '', // 行政信息描述
        jud_des: '', // 司法信息描述
        involved_des: '', // 涉诉信息数
        census_opinion: '', // 授信建议量的有关说明
      },
      dataCensusSolid: {},
      // PEST
      pestId: '',
      dataPest: {
        p: '',
        e: '',
        s: '',
        t: '',
        customer_related_id: '',
      },
      dataPestSolid: {},
      // 供销商
      dataBusinessSupplier: [], // 供货商
      dataBusinessSeller: [], // 销售商
      dataBusinessSupplierFunds: 0,
      dataBusinessSellerFunds: 0,
      // 经营资产信息 datum_customer_business_produce
      dataBusinessProduce: [],
      // 设备设施 datum_customer_business_facilities
      dataBusinessFacilities: [],
      // 生产设施 datum_customer_business_fac_produce
      dataBusinessFacProduce: [],
      // 生物/存货资产 datum_customer_bio_assets
      dataBioAssets: [],
      bioVisible: false,
      bioSelect: {},
      // 银行流水 datum_customer_finance_bank_account
      dataFinanceBackAccount: [],
      // 银行流水明细 datum_customer_finance_bank
      // 农业保险 datum_customer_business_insurance
      dataBusinessInsurance: [],
      // 工商信息
      businessInfoId: '',
      dataBusinessInfo: {
        customer_related_id: '',
        register_no: '', // 统一信用代码
        register_status: '', // 登记状态
        bussiness_type: '', // 状态
        approved_date: '', // 核准日期->成立日期 @20190120_唐文峰
        register_organ: '', // 登记机关
      },
      dataBusinessInfoSolid: {},
      // 工商变更信息 datum_customer_business_change
      dataBusinessChange: [],
      busChangeVisible: false,
      busChangeSelect: {},
      // 股东关联公司 datum_customer_business_assoc
      dataBusinessAssoc: [],
      busAssocVisible: false,
      busAssocSelect: {},
      // 对外担保 datum_customer_warrant_foreign
      dataWarrentForeign: [],
      // 农场区县和乡镇地址码
      infoAddressCodeCity: '',
      infoAddressCodeTown: '',
      // 行业分析 datum_customer_industry_posit_analysis
      positAnalysisId: '',
      dataPositAnalysis: {
        customer_related_id: '',
        rank_analysis: '分析：', // 区域内行业地位
        concent_analysis: '分析：', // 区县产业集中度
        concent_analysis_vil: '分析：', // 乡镇产业集中度
      },
      dataPositAnalysisSolid: {},
      // 用工情况 datum_customer_emp
      dataCustomerEmp: {},
      // 行政信息 datum_customer_admin_info @20190120_唐文峰_#文本变更为表格
      dataAdminInfo: [],
      adminInfoVisible: false,
      adminInfoSelect: {},

      // 保存
      focusFromReport: false,
      saveLoading: false,

      // 目录
      dataMenu: [],
      dataMenuSolid: [],
      menuVisible: false,
      menuList: [
        {
          title: '报告摘要',
          anchor: 'anchor-desc',
        },
        {
          title: '主要结论',
          anchor: 'anchor-conc',
        },
        {
          title: '一、经营分析',
          anchor: 'anchor-1',
          children: [
            {
              title: '1. 行业分析',
              anchor: 'anchor-1-1',
            },
            {
              title: '2. 经营分析',
              anchor: 'anchor-1-2',
              children: [
                {
                  title: '2.1 历史沿革',
                  anchor: 'anchor-1-2-1',
                },
                {
                  title: '2.2 经营业务',
                  anchor: 'anchor-1-2-2',
                },
                {
                  title: '2.3 经营模式',
                  anchor: 'anchor-1-2-3',
                },
                {
                  title: '2.4 公司荣誉',
                  anchor: 'anchor-1-2-4',
                },
                {
                  title: '2.5 知识产权及经营许可',
                  anchor: 'anchor-1-2-5',
                },
              ],
            },
            {
              title: '3. 公司管理',
              anchor: 'anchor-1-3',
              children: [
                {
                  title: '3.1 组织架构',
                  anchor: 'anchor-1-3-1',
                },
                {
                  title: '3.2 核心团队',
                  anchor: 'anchor-1-3-2',
                },
                {
                  title: '3.3 用工分析',
                  anchor: 'anchor-1-3-3',
                },
              ],
            },
            {
              title: '4. 经营资产信息',
              anchor: 'anchor-1-4',
              children: [
                {
                  title: '4.1 基础条件',
                  anchor: 'anchor-1-4-1',
                },
                {
                  title: '4.2 设备设施',
                  anchor: 'anchor-1-4-2',
                },
                {
                  title: '4.3 生物资产',
                  anchor: 'anchor-1-4-3',
                },
              ],
            },
            {
              title: '5. 用电情况分析',
              anchor: 'anchor-1-5',
            },
            {
              title: '6. 公司竞争力分析',
              anchor: 'anchor-1-6',
            },
          ],
        },
        {
          title: '二、财务分析',
          anchor: 'anchor-2',
          children: [
            {
              title: '1. 资金来源分析',
              anchor: 'anchor-2-1',
            },
            {
              title: '2. 项目投入分析',
              anchor: 'anchor-2-2',
              children: [
                {
                  title: '2.1 固定投入',
                  anchor: 'anchor-2-2-1',
                },
                {
                  title: '2.2 流动投入',
                  anchor: 'anchor-2-2-2',
                },
              ],
            },
            {
              title: '3. 收入分析',
              anchor: 'anchor-2-3',
            },
            {
              title: '4. 偿债能力分析',
              anchor: 'anchor-2-4',
            },
          ],
        },
        {
          title: '三、信用分析',
          anchor: 'anchor-3',
          children: [
            {
              title: '1. 工商信用',
              anchor: 'anchor-3-1',
              children: [
                {
                  title: '1.1 工商基本信息',
                  anchor: 'anchor-3-1-1',
                },
                {
                  title: '1.2 股权结构',
                  anchor: 'anchor-3-1-2',
                },
                {
                  title: '1.3 工商变更信息',
                  anchor: 'anchor-3-1-3',
                },
                {
                  title: '1.4 关联信息',
                  anchor: 'anchor-3-1-4',
                },
              ],
            },
            {
              title: '2. 银行征信',
              anchor: 'anchor-3-2',
              children: [
                {
                  title: '2.1 征信信息',
                  anchor: 'anchor-3-2-1',
                },
                {
                  title: '2.2 征信分析',
                  anchor: 'anchor-3-2-2',
                },
                {
                  title: '2.3 对外担保情况',
                  anchor: 'anchor-3-3-3',
                },
              ],
            },
            {
              title: '3. 行政信息',
              anchor: 'anchor-3-3',
            },
            {
              title: '4. 司法信息',
              anchor: 'anchor-3-4',
            },
          ],
        },
        {
          title: '四、大数据评级及授信建议量的有关说明',
          anchor: 'anchor-4',
        },
      ],
      // 分值等级
      scoreLevel: [
        { score: 10, color: '#ff0200' },
        { score: 20, color: '#ff3300' },
        { score: 30, color: '#ff6600' },
        { score: 40, color: '#ff9900' },
        { score: 50, color: '#ffcc00' },
        { score: 60, color: '#ffff00' },
        { score: 70, color: '#ccff00' },
        { score: 80, color: '#99ff00' },
        { score: 90, color: '#66ff00' },
        { score: 100, color: '#33ff00' },
      ],
      levelDivide: [
        { label: 'D', area: 5 },
        { label: 'C', area: 1 },
        { label: 'B', area: 1 },
        { label: 'A', area: 3 },
      ],
    }
  },
  computed: {
    showRatingReport() {
      return this.ratingStatus === 1 || this.ratingStatus === 2
    },
    org() {
      return this.$store.getters.org
    },
    orgLogo() {
      let images = this.org.orgImages
      if (images) {
        let arr = images.replace(/^\["(\S+)"\]$/, '$1').split('","')
        return arr.length ? arr[0] : ''
      } else {
        return ''
      }
    },
    pestImage() {
      return require('../../../assets/img/pest.png')
    },
    startValidityPeriod() {
      return this.dataCensusSolid.start_validity_period
        ? this.$utils.dateFormat(this.dataCensusSolid.start_validity_period, 'yyyy年M月d日')
        : '     年   月   日'
    },
    endValidityPeriod() {
      return this.dataCensusSolid.end_validity_period
        ? this.$utils.dateFormat(this.dataCensusSolid.end_validity_period, 'yyyy年M月d日')
        : '     年   月   日'
    },
    dataFundsPercent() {
      return this.dataFunds.inputs
        ? `${Math.round((this.dataFunds.funds / this.dataFunds.inputs) * 10000) / 100}%`
        : ''
    },
  },
  watch: {
    relatedId() {
      this.init()
    },
  },
  created() {
    this.ratingStatus = sessionStorage.getItem('ratingStatus')
    window.addEventListener('resize', this.initHeight)
    this.init()
  },
  mounted() {},
  methods: {
    formatLine,
    init() {
      this.initHeight()

      this.customerRelatedId = this.relatedId || this.$route.query.id
      if (!this.customerRelatedId) {
        return false // this.$message.error('获取客户信息失败！')
        // this.$router.back()
      }

      this.dataPest.customer_related_id = this.customerRelatedId
      this.dataPestSolid = { ...this.dataPest }

      this.dataCensus.customer_related_id = this.customerRelatedId

      this.dataBusinessInfo.customer_related_id = this.customerRelatedId
      this.dataBusinessInfoSolid = { ...this.dataBusinessInfo }

      this.dataPositAnalysis.customer_related_id = this.customerRelatedId
      this.dataPositAnalysisSolid = { ...this.dataPositAnalysis }

      this.getData()
    },

    initHeight() {
      const clientHeight =
        document.documentElement.clientHeight || document.body.clientHeight || window.innerHeight
      this.height = clientHeight - 210
    },

    // 客户及关联信息
    getData() {
      this.getDataBase()
      this.getDataBaseSh()
      this.getLevelCustomer()
      this.getLevelScore()
      // this.getLevelReport()
      this.getCensusReport()
      this.getAndCopyMenu()
      this.getFinanceCapitalSource()
      this.getFinanceProjectInput()
      this.getDataProduct()
      this.getPest()
      this.getAdminInfo()
      this.getBusinessSm()
      this.getBusinessProduce()
      this.getBusinessFacilities()
      this.getFinanceBackAccount()
      this.getBusinessInsurance()
      this.getBusinessInfo()
      this.getBusinessChange()
      this.getWarrent()
      this.getPositAnalysis()
      this.getCustomerEmp()
    },

    // 关联基本信息
    async getDataBase() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'customer_related_view', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res && res.data && res.data.data && res.data.data.length) {
        this.dataBase = res.data.data[0]
        // 累积负债
        const enDebt = Number.parseFloat(this.dataBase.en_debt)
        const personalDebt = Number.parseFloat(this.dataBase.personal_debt)
        let debt = isNaN(enDebt) ? 0 : enDebt
        debt += isNaN(personalDebt) ? 0 : personalDebt
        this.dataFunds.debt = Math.round(debt * 10000) / 10000

        this.dataCensus.customer_id = this.dataBase.customer_id
        this.dataCensusSolid = { ...this.dataCensus }

        // 预审金额（关联表的审批金额 是预审金额 @石勇）
        if (!this.dataCensus.eva_funds) {
          this.dataCensus.eva_funds = this.dataBase.approved_funds
        }

        this.getDataBaseInfo()

        if (this.dataBase.farm_type === '2') {
          this.getBusinessFacProduce()
        }

        // 收入分析图标
        this.setChartInputOption()
      } else {
        // return this.$message.error('获取客户信息失败，请重试！')
      }
    },

    // 企业基本信息
    async getDataBaseInfo() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_info', {
          index: 1,
          size: 1,
          'customer_id.eq': this.dataBase.customer_id,
        })
      )
      this.loading = false
      if (res && res.data && res.data.data && res.data.data.length) {
        this.dataBaseInfo = res.data.data[0]
        this.dataBusinessInfo.register_no = this.dataBaseInfo.register_no
        this.getAddressCode()
      } else {
        // return this.$message.error('获取客户信息失败，请重试！')
      }
    },

    getAddressCode() {
      let code = this.dataBaseInfo.address_code
      code = Number.parseInt(code)
      code = isNaN(code) ? 0 : code
      if (!code) {
        return false
      }

      // 区县 5206 00 000 000
      const city = Math.floor(code / Math.pow(10, 8))
      if (city % 100 > 0) {
        this.infoAddressCodeCity = `${city}${Array(8).join('0')}`
        const town = Math.floor(code / Math.pow(10, 6))
        if (town % 100 > 0) {
          this.infoAddressCodeTown = `${town}${Array(6).join('0')}`
        }
      }
    },

    // 法人/股东信息
    async getDataBaseSh() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_shareholder_view', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (!res || !res.data) {
        return
      }

      for (const rd of res.data) {
        rd.handEdu = []
        rd.workExp = []
        if (rd.is_corp === '1') {
          this.dataInfoLegal = rd
        } else if (rd.is_corp === '2') {
          this.dataInfoSpouse = rd
        }
        if (rd.is_actual_controller === '1') {
          this.dataInfoControl = rd
        }
      }
      this.dataInfoSh = res.data
      this.getCredit()
      this.getHandEducation()
      this.getWorkExp()
    },

    // 受教育情况
    async getHandEducation() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_hand_education', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )

      if (res) {
        // 给每个员工添加受教育情况
        const data = res.data || []
        for (const d of this.dataInfoSh) {
          d.handEdu = []
          for (let i = 0; i < data.length; i++) {
            const he = data[i]
            if (he.datum_customer_shareholder_id === d.datum_customer_shareholder_id) {
              he.datePeriod = `${this.$utils.dateFormat(
                he.start_date,
                'yyyy.MM'
              )}-${this.$utils.dateFormat(he.end_date, 'yyyy.MM')}`
              d.handEdu.push(he)
              data.splice(i, 1)
            }
          }
          if (!d.handEdu.length) {
            d.handEdu.push({
              datePeriod: '-',
              age_inter: '-',
              customer_name: '-',
              education_mech: '-',
              end_date: '-',
              profession: '-',
              remark: '-',
              start_date: '-',
            })
          }
        }
      }
    },

    // 工作经历
    async getWorkExp() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_work_exp', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )

      if (res) {
        // 给每个员工添加工作经历
        const data = res.data || []
        for (const d of this.dataInfoSh) {
          d.workExp = []
          for (let i = 0; i < data.length; i++) {
            const we = data[i]
            if (we.datum_customer_shareholder_id === d.datum_customer_shareholder_id) {
              we.datePeriod = `${this.$utils.dateFormat(
                we.start_date,
                'yyyy.MM'
              )}-${this.$utils.dateFormat(we.end_date, 'yyyy.MM')}`
              d.workExp.push(we)
              data.splice(i, 1)
            }
          }
          if (!d.workExp.length) {
            d.workExp.push({
              datePeriod: '-',
              age_inter: '-',
              customer_name: '-',
              work_unit: '-',
              end_date: '-',
              assets_total: '-',
              remark: '-',
              start_date: '-',
            })
          }
        }
      }
    },

    async getAndCopyMenu() {
      // DEFAULT_STRUCTURE
      let [res, err] = await this.getMenu()

      if (err) {
        return this.$message.error('获取评级目录失败，请刷新重试！')
      }

      if (res && res.data) {
        this.dataMenu = res.data
      } else {
        this.copyMenu()
      }
    },

    async copyMenu() {
      // 没有添加目录，把默认目录复制一份
      const [def] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'credit_report_dir_structure', {
          'customer_related_id.eq': 'DEFAULT_STRUCTURE',
        })
      )
      if (def && def.data) {
        const data = def.data.map(item => {
          return {
            customer_related_id: this.customerRelatedId,
            dir_lever: item.dir_lever,
            dir_name: item.dir_name,
            dir_page_num: item.dir_page_num,
            order_num: item.order_num,
          }
        })
        const [, ae] = await this.$utils.promise(
          this.$api.addBatch(CREDIT_SERVER, 'credit_report_dir_structure', data)
        )
        if (ae) {
          return this.$message.error('创建评级目录失败，请刷新重试！')
        }
        this.getMenu()
      } else {
        return this.$message.error('获取默认目录失败，请刷新重试！')
      }
    },

    getMenu() {
      return this.$api
        .getData(
          CREDIT_SERVER,
          'credit_report_dir_structure',
          {
            'customer_related_id.eq': this.customerRelatedId,
          },
          { N2order_num: 'asc' }
        )
        .then(res => {
          if (res && res.data) {
            this.dataMenu = res.data
            this.dataMenuSolid = this.dataMenu.map(item => {
              return { ...item }
            })
          }
          return [res, null]
        })
        .catch(err => {
          return [null, err]
        })
    },

    // 资金来源明细
    async getFinanceCapitalSource() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_finance_capital_source', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      if (res && res.data) {
        let selfTotal = 0
        let total = 0
        for (const d of res.data) {
          const t = Number.parseFloat(d.funds)
          const o = isNaN(t) ? 0 : t
          total += o
          d.o = o
          if (d.capital_source_key === 'self_funds') {
            selfTotal += o
          }
        }
        // 累积自有资金
        this.dataFunds.funds = Math.round(selfTotal * 100) / 100
        // 明细
        this.dataFinanceCapitalSourceTotal = Math.round(total * 100) / 100
        this.dataFinanceCapitalSource = res.data.map(item => {
          item.percent = total > 0 ? `${Math.round((item.o / total) * 10000) / 100}%` : '-'
          return item
        })
      } else {
        this.dataFinanceCapitalSource = []
        this.dataFinanceCapitalSourceTotal = 0
      }
    },

    // 项目固定投入明细 项目流动资金投入明细
    async getFinanceProjectInput() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_finance_project_input', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.dataFinanceProjectInputSolid = []
      this.dataFinanceProjectInputSolidTotal = 0
      this.dataFinanceProjectInputFlow = []
      this.dataFinanceProjectInputFlowTotal = 0
      if (res && res.data) {
        let total = 0
        let solidTotal = 0
        let flowTotal = 0
        for (const d of res.data) {
          const t = Number.parseFloat(d.funds)
          const o = isNaN(t) ? 0 : t
          total += o
          if (d.input_type === '1') {
            this.dataFinanceProjectInputSolid.push(d)
            solidTotal += o
          } else {
            this.dataFinanceProjectInputFlow.push(d)
            flowTotal += o
          }
        }
        this.dataFunds.inputs = Math.round(total * 100) / 100
        this.dataFinanceProjectInputSolidTotal = Math.round(solidTotal * 100) / 100
        this.dataFinanceProjectInputFlowTotal = Math.round(flowTotal * 100) / 100
      }
    },

    // 结论
    async getLevelReport() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'credit_level_report', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      if (res && res.data && res.data.data && res.data.data.length) {
        this.dataReportSolid = res.data.data[0]
        this.dataReport = { ...this.dataReportSolid }
      }
    },

    // 尽调报告
    async getCensusReport() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'credit_census_report', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      if (res && res.data && res.data.data && res.data.data.length) {
        const data = res.data.data[0]
        this.censusId = data.id
        Object.keys(this.dataCensus).forEach(key => {
          this.dataCensus[key] = data[key]
        })
        this.dataCensusSolid = { ...this.dataCensus }
      }
    },

    // 产业规模
    async getDataProduct() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(
          CREDIT_SERVER,
          'datum_customer_industrial',
          {
            'customer_related_id.eq': this.customerRelatedId,
          },
          { scale: 'desc' }
        )
      )
      this.loading = false
      if (res && res.data) {
        this.dataProduct = res.data
        for (const p of this.dataProduct) {
          // 主导（营）产品
          if (p.is_main_product === '1') {
            this.dataProductMain = p
          }
        }
      } else {
        this.dataProduct = []
      }
      this.getIndustryAnalysisAutoAdd()
      this.getBioAssetsAutoAdd()
    },

    // 产业分析
    async getIndustryAnalysisAutoAdd() {
      const [data] = await this.getIndustryAnalysis()

      if (!data && this.dataProductMain.category_code) {
        // 添加一个主导产品分析
        const [res] = await this.addIndustryAnalysis(
          this.dataProductMain.category_code,
          this.dataProductMain.product_name
        )
        if (res) {
          this.getIndustryAnalysis()
        }
      }
    },

    async getIndustryAnalysis() {
      this.loading = true
      const [res, err] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_industry_analysis', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (err) {
        return [null, err]
      }

      if (res && res.data) {
        this.dataIndustryAnalysis = res.data.map(item => {
          const pDim = (item.price_analysis_dim || '').split(',') || []
          const mDim = (item.material_analysis_dim || '').split(',') || []
          item.price_analysis_dim = pDim.filter(v => !!v)
          item.material_analysis_dim = mDim.filter(v => !!v)
          return item
        })
        return [res.data, null]
      } else {
        this.dataIndustryAnalysis = []
      }

      return [null, null]
    },

    async addIndustryAnalysis(categoryCode, productName) {
      this.loading = true
      const data = {
        customer_related_id: this.customerRelatedId,
        material_analysis_dim: 'year,month',
        price_analysis_dim: 'year,month',
        product_name: productName,
      }
      if (categoryCode) {
        data.category_code = categoryCode
      }
      const [res] = await this.$utils.promise(
        this.$api.addData(CREDIT_SERVER, 'datum_customer_industry_analysis', data)
      )
      this.loading = false
      if (res && res.data) {
        this.getIndustryAnalysis()
        return [res]
      }
      return [null]
    },

    async updateIndustryAnalysis(row) {
      const [, err] = await this.$utils.promise(
        this.$api.updateData(
          CREDIT_SERVER,
          'datum_customer_industry_analysis',
          row.datum_customer_industry_analysis_id,
          {
            category_code: row.category_code,
            product_name: row.product_name,
            price_analysis_dim: row.price_analysis_dim.join(','),
            price_analysis: row.price_analysis,
            material_category_code: row.material_category_code,
            material_name: row.material_name,
            material_analysis_dim: row.material_analysis_dim.join(','),
            material_analysis: row.material_analysis,
          }
        )
      )
      if (err) {
        return this.$message.error('保存失败，请重试！')
      }
      this.$message.success('保存成功！')
    },

    async deleteIndustryAnalysis(id) {
      const [, err] = await this.$utils.promise(
        this.$api.deleteData(CREDIT_SERVER, 'datum_customer_industry_analysis', id)
      )
      if (err) {
        return this.$message.error('删除失败')
      }
      this.getIndustryAnalysis()
    },

    onIndustryAnalysisMainChange(index, val, name) {
      const n = name.length ? name[name.length - 1] : ''
      this.dataIndustryAnalysis[index].product_name = n
    },

    onIndustryAnalysisMaterialChange(index, val, name) {
      const n = name.length ? name[name.length - 1] : ''
      this.dataIndustryAnalysis[index].material_name = n
    },

    // 银行征信情况
    async getCredit() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_credit', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false
      if (res) {
        this.dataCredit = res.data || []
      } else {
        this.dataCredit = []
      }
    },

    // 评分过程
    async getLevelCustomer() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(
          CREDIT_SERVER,
          'credit_level_customer',
          {
            'customer_related_id.eq': this.customerRelatedId,
          },
          { order_num: 'asc' }
        )
      )
      this.loading = false
      if (res && res.data && res.data.length) {
        this.dataScoreFirstList = [] // 一类指标表格
        this.dataScoreLoseList = [] // 扣分项

        const data = calcSpan(res.data, 'first_level_norm_name')

        for (const cs of data) {
          if (cs.is_deductions !== '0') {
            // 扣分项
            // 显示负负号
            if (+cs.norm_weight !== 0) {
              cs.norm_weight = `-${cs.norm_weight}`
            } else {
              cs.norm_weight = 0 // 格式化0.00
            }
            if (+cs.weight_score === 0) {
              cs.weight_score = 0 // 格式化0.000
            }
            this.dataScoreLoseList.push(cs)
          } else {
            if (cs.rowspan > 0) {
              // 一类指标
              this.dataScoreFirstList.push({
                name: cs.first_level_norm_name,
                score: +cs.weight_score || 0,
                totalScore: +cs.norm_weight || 0,
                percent: 0,
                score_a: false,
                score_b: false,
                score_c: false,
              })
            } else {
              // 一类指标累加
              const lastFl = this.dataScoreFirstList[this.dataScoreFirstList.length - 1]
              lastFl.score += +cs.weight_score || 0
              lastFl.totalScore += +cs.norm_weight || 0
            }
          }
        }

        // 一类指标得分
        for (let fl of this.dataScoreFirstList) {
          fl.score = fixed(fl.score)
          fl.percent = fl.totalScore > 0 ? fl.score / fl.totalScore : 0
          if (fl.percent >= 80) {
            fl.score_a = true
          } else if (fl.percent >= 60) {
            fl.score_b = true
          } else {
            fl.score_c = true
          }
          fl.percent = fixed(fl.percent)
          fl.totalScore = fixed(fl.totalScore * 100)
        }
      }
    },

    // 得分及等级
    async getLevelScore() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'credit_level_score', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      if (res && res.data && res.data.data && res.data.data.length) {
        const data = res.data.data[0]
        this.dataScoreApiLevel = data.score_level || ''
        this.dataScoreApiScore = data.score || '0'
      } else {
        return this.$message.warning('暂无评级得分数据！')
      }
    },

    async getPest() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_pest', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res && res.data && res.data.data && res.data.data.length) {
        const data = res.data.data[0]
        this.pestId = data.datum_customer_pest_id
        Object.keys(this.dataPest).forEach(key => {
          this.dataPest[key] = data[key]
        })
        this.dataPestSolid = { ...this.dataPest }
      }
    },

    async getBusinessSm() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_sm', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      this.dataBusinessSupplier = []
      this.dataBusinessSeller = []
      this.dataBusinessSupplierFunds = 0
      this.dataBusinessSellerFunds = 0
      if (res && res.data) {
        for (const data of res.data) {
          if (data.sm_type === '1') {
            this.dataBusinessSupplier.push(data)
            const funds = Number.parseFloat(data.current_year_total || 0)
            this.dataBusinessSupplierFunds += isNaN(funds) ? 0 : funds
          } else {
            this.dataBusinessSeller.push(data)
            const funds = Number.parseFloat(data.current_year_total || 0)
            this.dataBusinessSellerFunds += isNaN(funds) ? 0 : funds
          }
        }
      }
      this.dataBusinessSupplierFunds = Math.round(this.dataBusinessSupplierFunds * 100) / 100
      this.dataBusinessSellerFunds = Math.round(this.dataBusinessSellerFunds * 100) / 100
    },

    async getBusinessProduce() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_produce', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res) {
        this.dataBusinessProduce = res.data || []
      }
    },

    async getBusinessFacilities() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_facilities', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res) {
        this.dataBusinessFacilities = res.data || []
      }
    },

    async getBioAssetsAutoAdd() {
      const [data] = await this.getBioAssets()

      if (data && !data.length && this.dataProduct.length) {
        // 复制一份产品数据
        const form = this.dataProduct.map(item => {
          return {
            customer_related_id: this.customerRelatedId,
            product_name: item.product_name,
            base_type: item.base_type,
            base_type_name: item.base_type_name,
            scale: item.scale,
            uscale: item.uscale,
          }
        })
        const [ar] = await this.$utils.promise(
          this.$api.addBatch(CREDIT_SERVER, 'datum_customer_bio_assets', form)
        )
        if (ar) {
          this.getBioAssets()
        }
      }
    },

    async getBioAssets() {
      const [res, err] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_bio_assets', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )

      if (err) {
        return [null, err]
      }

      if (res) {
        const data = res.data || []
        this.dataBioAssets = data
        return [data, err]
      }
      return [[], err]
    },

    beforeBioClose() {
      this.bioSelect = {}
      this.bioVisible = false
    },

    onBioEdit(row) {
      this.bioSelect = row
      this.bioVisible = true
    },

    onBioDelete(row) {
      this.deleteMsgBox({
        message: '确定删除该产品？',
        beforeClose: async () => {
          await this.$api.deleteData(
            CREDIT_SERVER,
            'datum_customer_bio_assets',
            row.datum_customer_bio_assets_id
          )
        },
        afterClose: this.getBioAssets,
      })
    },

    onBioBaseTypeChange(val, name) {
      this.bioSelect.base_type_name = name
    },

    async onBioSave() {
      const data = {
        assets_value: this.bioSelect.assets_value,
        base_type: this.bioSelect.base_type,
        base_type_name: this.bioSelect.base_type_name,
        product_name: this.bioSelect.product_name,
        scale: this.bioSelect.scale,
        store: this.bioSelect.store,
        unit_price: this.bioSelect.unit_price,
        uscale: this.bioSelect.uscale,
      }
      if (this.bioSelect.datum_customer_bio_assets_id) {
        // 修改
        const [res] = await this.$utils.promise(
          this.$api.updateData(
            CREDIT_SERVER,
            'datum_customer_bio_assets',
            this.bioSelect.datum_customer_bio_assets_id,
            data
          )
        )
        if (res) {
          this.beforeBioClose()
          this.getBioAssets()
          return this.$message.success('修改成功！')
        }
        this.$message.error('修改失败！')
      } else {
        // 添加
        data.customer_related_id = this.customerRelatedId
        const [res] = await this.$utils.promise(
          this.$api.addData(CREDIT_SERVER, 'datum_customer_bio_assets', data)
        )
        if (res) {
          this.beforeBioClose()
          this.getBioAssets()
          return this.$message.success('添加成功！')
        }
        this.$message.error('添加失败！')
      }
    },

    // 工商变更
    async getBusinessChange() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_change', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )

      if (res) {
        this.dataBusinessChange = res.data || []
      }
    },

    beforeBusChangeClose() {
      this.busChangeSelect = {}
      this.busChangeVisible = false
    },

    onBusChangeEdit(row) {
      this.busChangeSelect = row
      this.busChangeVisible = true
    },

    onBusChangeDelete(row) {
      this.deleteMsgBox({
        message: '确定删除该工商变更信息？',
        beforeClose: async () => {
          await this.$api.deleteData(
            CREDIT_SERVER,
            'datum_customer_business_change',
            row.datum_customer_business_change_id
          )
        },
        afterClose: this.getBusinessChange,
      })
    },

    async onBusChangeSave() {
      const data = {
        after_content: this.busChangeSelect.after_content,
        before_content: this.busChangeSelect.before_content,
        change_date: this.busChangeSelect.change_date,
        change_item: this.busChangeSelect.change_item,
      }
      if (this.busChangeSelect.datum_customer_business_change_id) {
        // 修改
        const [res] = await this.$utils.promise(
          this.$api.updateData(
            CREDIT_SERVER,
            'datum_customer_business_change',
            this.busChangeSelect.datum_customer_business_change_id,
            data
          )
        )
        if (res) {
          this.beforeBusChangeClose()
          this.getBusinessChange()
          return this.$message.success('修改成功！')
        }
        this.$message.error('修改失败！')
      } else {
        // 添加
        data.customer_related_id = this.customerRelatedId
        const [res] = await this.$utils.promise(
          this.$api.addData(CREDIT_SERVER, 'datum_customer_business_change', data)
        )
        if (res) {
          this.beforeBusChangeClose()
          this.getBusinessChange()
          return this.$message.success('添加成功！')
        }
        this.$message.error('添加失败！')
      }
    },

    // 股东关联公司
    async getBusinessAssoc() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_assoc', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )

      if (res) {
        this.dataBusinessAssoc = res.data || []
      }
    },

    beforeBusAssocClose() {
      this.busAssocSelect = {}
      this.busAssocVisible = false
    },

    onBusAssocEdit(row) {
      this.busAssocSelect = row
      this.busAssocVisible = true
    },

    onBusAssocDelete(row) {
      this.deleteMsgBox({
        message: '确定删除该股东关联公司？',
        beforeClose: async () => {
          await this.$api.deleteData(
            CREDIT_SERVER,
            'datum_customer_business_assoc',
            row.datum_customer_business_assoc_id
          )
        },
        afterClose: this.getBusinessAssoc,
      })
    },

    async onBusAssocSave() {
      const data = {
        assoc_entity_name: this.busAssocSelect.assoc_entity_name,
        assoc_type: this.busAssocSelect.assoc_type,
        com_status: this.busAssocSelect.com_status,
        corp_name: this.busAssocSelect.corp_name,
        registered_capital: this.busAssocSelect.registered_capital,
        registered_date: this.busAssocSelect.registered_date,
        register_address: this.busAssocSelect.register_address,
      }
      if (this.busAssocSelect.datum_customer_business_assoc_id) {
        // 修改
        const [res] = await this.$utils.promise(
          this.$api.updateData(
            CREDIT_SERVER,
            'datum_customer_business_assoc',
            this.busAssocSelect.datum_customer_business_assoc_id,
            data
          )
        )
        if (res) {
          this.beforeBusAssocClose()
          this.getBusinessAssoc()
          return this.$message.success('修改成功！')
        }
        this.$message.error('修改失败！')
      } else {
        // 添加
        data.customer_related_id = this.customerRelatedId
        data.customer_id = this.dataBaseInfo.customer_id
        data.customer_name = this.dataBaseInfo.customer_name
        const [res] = await this.$utils.promise(
          this.$api.addData(CREDIT_SERVER, 'datum_customer_business_assoc', data)
        )
        if (res) {
          this.beforeBusAssocClose()
          this.getBusinessAssoc()
          return this.$message.success('添加成功！')
        }
        this.$message.error('添加失败！')
      }
    },

    // 行政信息 -> 变更为表格内容
    async getAdminInfo() {
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_admin_info', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )

      if (res) {
        this.dataAdminInfo = res.data || []
      }
    },

    beforeAdminInfoClose() {
      this.adminInfoSelect = {}
      this.adminInfoVisible = false
    },

    onAdminInfoEdit(row) {
      this.adminInfoSelect = row
      this.adminInfoVisible = true
    },

    onAdminInfoDelete(row) {
      this.deleteMsgBox({
        message: '确定删除该行政信息？',
        beforeClose: async () => {
          await this.$api.deleteData(CREDIT_SERVER, 'datum_customer_admin_info', row.id)
        },
        afterClose: this.getAdminInfo,
      })
    },

    async onAdminInfoSave() {
      this.$refs.adminInfoForm.validate(valid => {
        if (valid) {
          this.doAdminInfoSave()
        } else {
          this.$message.error('输入错误，请检查您的输入！')
        }
      })
    },

    async doAdminInfoSave() {
      const data = {
        license_agency: this.adminInfoSelect.license_agency,
        license_centent: this.adminInfoSelect.license_centent,
        license_name: this.adminInfoSelect.license_name,
        license_no: this.adminInfoSelect.license_no,
        period_start: this.adminInfoSelect.period_start,
        period_end: this.adminInfoSelect.period_end,
      }
      if (this.adminInfoSelect.id) {
        // 修改
        const [res] = await this.$utils.promise(
          this.$api.updateData(
            CREDIT_SERVER,
            'datum_customer_admin_info',
            this.adminInfoSelect.id,
            data
          )
        )
        if (res) {
          this.beforeAdminInfoClose()
          this.getAdminInfo()
          return this.$message.success('修改成功！')
        }
        this.$message.error('修改失败！')
      } else {
        // 添加
        data.customer_related_id = this.customerRelatedId
        const [res] = await this.$utils.promise(
          this.$api.addData(CREDIT_SERVER, 'datum_customer_admin_info', data)
        )
        if (res) {
          this.beforeAdminInfoClose()
          this.getAdminInfo()
          return this.$message.success('添加成功！')
        }
        this.$message.error('添加失败！')
      }
    },

    async getBusinessFacProduce() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_fac_produce', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res) {
        this.dataBusinessFacProduce = res.data || []
      }
    },

    onInitChartInput(chart) {
      this.chartInput = chart
      this.chartInput.on('finished', () => {
        this.chartInputImgData = this.chartInput.getDataURL()
      })
    },

    setChartInputOption() {
      const n1 = this.dataBase.last_year_income || '-'
      const n2 = this.dataBase.current_year_income || '-'
      const n3 = this.dataBase.next_year_income || '-'
      // 计算增长率
      let a1 = Number.parseFloat(n1)
      a1 = isNaN(a1) ? 0 : a1
      let a2 = Number.parseFloat(n2)
      a2 = isNaN(a2) ? 0 : a2
      let a3 = Number.parseFloat(n3)
      a3 = isNaN(a3) ? 0 : a3
      const z1 = '-'
      const z2 = a1 > 0 ? Math.round(((a2 - a1) / a1) * 10000) / 100 : '-'
      const z3 = a2 > 0 ? Math.round(((a3 - a2) / a2) * 10000) / 100 : '-'
      this.chartInputOption = {
        backgroundColor: '#eff8fe',
        title: {
          text: '收入分析',
          left: 'center',
        },
        tooltip: {
          trigger: 'axis',
        },
        legend: {
          top: 32,
          data: ['金额（万元）', '增长率'],
        },
        xAxis: [
          {
            type: 'category',
            data: ['上年', '今年', '明年'],
          },
        ],
        yAxis: [
          {
            type: 'value',
            name: '金额（万元）',
          },
          {
            type: 'value',
            name: '增长率',
          },
        ],
        series: [
          {
            name: '金额（万元）',
            type: 'line',
            data: [n1, n2, n3],
          },
          {
            name: '增长率',
            type: 'line',
            data: [z1, z2, z3],
            yAxisIndex: 1,
          },
        ],
      }

      if (this.chartInput && this.chartInput.getDataURL) {
        this.chartInput.on('finished', () => {
          this.chartInputImgData = this.chartInput.getDataURL()
        })
      }
    },

    async getFinanceBackAccount() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_finance_bank_account', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false
      if (res) {
        this.dataFinanceBackAccount = res.data || []
        for (const d of this.dataFinanceBackAccount) {
          d.bankFlow = []
          this.$api
            .getData(
              CREDIT_SERVER,
              'datum_customer_finance_bank',
              {
                'datum_customer_finance_bank_account_id.eq':
                  d.datum_customer_finance_bank_account_id,
              },
              { N1year: 'asc', N2month: 'asc' }
            )
            .then(res => {
              if (res && res.data) {
                d.bankFlow = res.data
              }
            })
        }
      }
    },

    async getBusinessInsurance() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_insurance', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res) {
        this.dataBusinessInsurance = res.data || []
      }
    },

    async getBusinessInfo() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_business_info', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res && res.data && res.data.data && res.data.data.length) {
        const data = res.data.data[0]
        this.businessInfoId = data.datum_customer_business_info_id
        Object.keys(this.dataBusinessInfo).forEach(key => {
          this.dataBusinessInfo[key] = data[key]
        })
        this.dataBusinessInfoSolid = { ...this.dataBusinessInfo }
      }
    },

    async getWarrent() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_warrant_foreign', {
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res) {
        this.dataWarrentForeign = res.data || []
      }
    },

    async getPositAnalysis() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_industry_posit_analysis', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res && res.data && res.data.data && res.data.data.length) {
        const data = res.data.data[0]
        this.positAnalysisId = data.ddatum_customer_industry_posit_analysis_id
        Object.keys(this.dataPositAnalysis).forEach(key => {
          this.dataPositAnalysis[key] = data[key]
        })
        this.dataPositAnalysisSolid = { ...this.dataPositAnalysis }
      }
    },

    async getCustomerEmp() {
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData(CREDIT_SERVER, 'datum_customer_emp', {
          index: 1,
          size: 1,
          'customer_related_id.eq': this.customerRelatedId,
        })
      )
      this.loading = false

      if (res && res.data && res.data.data && res.data.data.length) {
        const d = res.data.data[0]
        this.dataCustomerEmp = d
        if (!this.dataCensus.management_model) {
          this.dataCensus.management_model = `总用工${d.emp_total || 0}人，其中常用工人有${
            d.emp_com_used || 0
          }人，临时工人有${d.emp_temp || 0}人，贫困户${d.poverty_households || 0}人。`
        }
      }
    },

    async onSave() {
      const saveList = [
        {
          service: CREDIT_SERVER,
          tableName: 'datum_customer_pest',
          dataForm: this.dataPest,
          solidForm: this.dataPestSolid,
          tableId: this.pestId,
        },
        {
          service: CREDIT_SERVER,
          tableName: 'credit_census_report',
          dataForm: this.dataCensus,
          solidForm: this.dataCensusSolid,
          tableId: this.censusId,
        },
        {
          service: CREDIT_SERVER,
          tableName: 'datum_customer_business_info',
          dataForm: this.dataBusinessInfo,
          solidForm: this.dataBusinessInfoSolid,
          tableId: this.businessInfoId,
        },
        {
          service: CREDIT_SERVER,
          tableName: 'datum_customer_industry_posit_analysis',
          dataForm: this.dataPositAnalysis,
          solidForm: this.dataPositAnalysisSolid,
          tableId: this.positAnalysisId,
        },
      ]

      const apiList = []
      let hasChange = false
      for (const sl of saveList) {
        const form = { ...sl.dataForm }
        const solidForm = { ...sl.solidForm }
        if (sl.convert) {
          Object.keys(sl.convert).forEach(k => {
            form[k] = sl.convert[k](form[k])
            solidForm[k] = sl.convert[k](solidForm[k])
          })
        }

        const keys = Object.keys(form)
        let isChange = false
        for (const key of keys) {
          if (form[key] !== solidForm[key]) {
            isChange = true
            break
          }
        }

        if (!isChange) {
          continue
        }

        hasChange = true

        if (sl.tableId) {
          apiList.push(this.$api.updateData(sl.service, sl.tableName, sl.tableId, form))
        } else {
          apiList.push(this.$api.addData(sl.service, sl.tableName, form))
        }
      }

      if (!hasChange) {
        return this.$message.info('没有要保存的内容')
      }

      this.saveLoading = true
      Promise.all(apiList)
        .then(() => {
          this.$message.success('保存成功！')
          this.getData()
        })
        .catch(() => {
          this.$message.error('保存失败！')
        })
        .then(() => {
          this.saveLoading = false
        })
    },

    onSaveMenu() {
      // 批量请求修改目录页码
      const changeMenu = []
      for (let i = 0; i < this.dataMenu.length; i++) {
        const page1 = this.dataMenuSolid[i].dir_page_num
        const page2 = this.dataMenu[i].dir_page_num

        if (page2 && page2 !== page1) {
          changeMenu.push(
            this.$api.updateData(
              CREDIT_SERVER,
              'credit_report_dir_structure',
              this.dataMenu[i].id,
              {
                dir_page_num: page2,
              }
            )
          )
        }
      }
      if (!changeMenu.length) {
        return this.$message.info('目录没有改变！')
      }
      Promise.all(changeMenu)
        .then(() => {
          this.$message.success('目录修改成功！')
          this.getMenu()
        })
        .catch(() => {
          this.$message.error('目录修改失败！')
        })
    },

    resetMenu() {
      this.$msgbox({
        title: '提示',
        message: this.$createElement('span', undefined, `确定重置目录（页码将重置为默认值）？`),
        showCancelButton: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: async (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true
            instance.confirmButtonText = '重置中...'

            // 批量删除
            const [dres] = await this.$utils.promise(
              this.$api.deleteDataBody(CREDIT_SERVER, 'credit_report_dir_structure', {
                customer_related_id: this.customerRelatedId,
              })
            )

            if (dres) {
              await this.copyMenu()
              this.$message.success('重置成功！')
              done()
            } else {
              this.$message.error('重置失败，请重试！')
            }

            instance.confirmButtonLoading = false
            instance.confirmButtonText = '确定'
          } else {
            done()
          }
        },
      }).catch(() => {})
    },

    onFinishCencus() {
      this.deleteMsgBox({
        message: '确定完成（完成后不能再修改）？',
        beforeClose: async () => {
          await this.$api.updateData(CREDIT_SERVER, 'credit_census_report', this.censusId, {
            census_status: 2,
            start_validity_period: this.$utils.dateFormat(new Date(), 'yyyy-MM-dd'),
            end_validity_period: this.$utils.dateFormat(
              new Date(new Date().getTime() + 60 * 24 * 60 * 60 * 1000),
              'yyyy-MM-dd'
            ),
          })
        },
        afterClose: () => {
          this.getData()
          this.$store.dispatch('getTaskCount')
        },
      })
    },

    deleteMsgBox({
      title = '提示',
      message = '确定删除？',
      beforeClose = () => {},
      afterClose = () => {},
      actionMessage = '删除中...',
      successMessage = '删除成功！',
      errorMessage = '删除失败，请重试！',
    }) {
      const self = this
      this.$msgbox({
        title: title,
        message: this.$createElement('span', undefined, message),
        showCancelButton: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: async (action, instance, done) => {
          function afterSuccess() {
            afterClose()
            self.$message.success(successMessage)
            instance.confirmButtonLoading = false
            instance.confirmButtonText = '确定'
            done()
          }

          if (action === 'confirm') {
            instance.confirmButtonLoading = true
            instance.confirmButtonText = actionMessage

            const before = beforeClose()
            if (before.then) {
              before
                .then(() => {
                  afterSuccess()
                })
                .catch(() => {
                  self.$message.error(errorMessage)
                })
            } else {
              afterSuccess()
            }
          } else {
            done()
          }
        },
      }).catch(() => {})
    },

    onPrint() {
      const str = document.getElementById('report-body').innerHTML
      printHtml(
        str,
        `
        .table-border-black tr > td, .table-border-black tr > th { border-color: #333 !important; font-size: 1.25rem;line-height: 1.5; }
        .table-bordered thead td, .table-bordered thead th {border-bottom-width: 1px;}
        .text-indent {text-indent: 3rem;}
      `
      )
    },
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.initHeight)
  },
  directives: {
    anchor: {
      bind(el, binding, vnode) {
        el.onclick = () => {
          const anchor = document.getElementById(binding.value)
          const target = document.getElementById(binding.arg || 'report-body')
          if (anchor && target) {
            scrollTo(target, anchor.offsetTop)
            if (binding.modifiers.focus) {
              vnode.context.focusFromReport = true
              anchor.focus()
              setTimeout(() => {
                vnode.context.focusFromReport = false
              }, 50)
            }
          }
        }
      },
    },
    focus: {
      bind(el, binding, vnode) {
        el.onfocus = () => {
          const anchor = document.getElementById(binding.value)
          const target = document.getElementById(binding.arg || 'report-body')
          const autoScroll = !vnode.context.focusFromReport
          if (anchor && target && autoScroll) {
            scrollTo(target, anchor.offsetTop)
            domAddClass(anchor, 'on-edit')
          }
        }
        el.onblur = () => {
          const anchor = document.getElementById(binding.value)
          if (anchor) {
            domRemoveClass(anchor, 'on-edit')
          }
        }
      },
    },
  },
}
</script>
<style lang="scss" scoped>
.scroll-y {
  overflow-y: auto;
  max-width: 1000px;
  @include scrollbar-theme();
}
.table-border-black {
  tr {
    th,
    td {
      border-color: #333 !important;
      font-size: 1.25rem;
      line-height: 1.5;
    }
  }
}
.text-indent {
  text-indent: 3rem;
}
.edit-eara {
  cursor: pointer;
  background-color: rgba(255, 255, 0, 0.05);
  transition: background-color 0.3s;
  min-width: 50px;
  min-height: 50px;
  vertical-align: middle;
  &:hover {
    background-color: rgba(255, 255, 0, 0.2);
  }
  &.on-edit {
    background-color: rgba(255, 255, 0, 0.2);
  }
}
.on-edit {
  .edit-eara {
    background-color: rgba(255, 255, 0, 0.2);
  }
}
</style>
